• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

lokalize

  • sources
  • kde-4.12
  • kdesdk
  • lokalize
  • src
  • catalog
gettextheader.cpp
Go to the documentation of this file.
1 /* ****************************************************************************
2  This file is part of Lokalize
3 
4  Copyright (C) 2008-2009 by Nick Shaforostoff <shafff@ukr.net>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License as
8  published by the Free Software Foundation; either version 2 of
9  the License or (at your option) version 3 or any later version
10  accepted by the membership of KDE e.V. (or its successor approved
11  by the membership of KDE e.V.), which shall act as a proxy
12  defined in Section 14 of version 3 of the license.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program. If not, see <http://www.gnu.org/licenses/>.
21 
22 **************************************************************************** */
23 
24 #include "gettextheader.h"
25 
26 #include "project.h"
27 
28 #include "version.h"
29 #include "prefs_lokalize.h"
30 
31 #include <QProcess>
32 #include <QString>
33 #include <QStringBuilder>
34 #include <QMap>
35 #include <QTextCodec>
36 
37 #include <kdebug.h>
38 #include <kglobal.h>
39 #include <klocale.h>
40 #include <kdatetime.h>
41 
42 #include <kio/netaccess.h>
43 #include <ktemporaryfile.h>
44 
49 #define NUM_LANG_WITH_INFO 40
50 static const char* langsWithPInfo[NUM_LANG_WITH_INFO]={
51 "ar",
52 "cs",
53 "da",
54 "de",
55 "el",
56 "en",
57 "en_GB",
58 "en_US",
59 "eo",
60 "es",
61 "et",
62 "fi",
63 "fo",
64 "fr",
65 "ga",
66 "he",
67 "hr",
68 "hu",
69 "it",
70 "ja",
71 "ko",
72 "lt",
73 "lv",
74 "nb",
75 "nl",
76 "nn",
77 "pl",
78 "pt",
79 "pt_BR",
80 "ro",
81 "ru",
82 "sk",
83 "sl",
84 "sr",
85 "sr@latin",
86 "sv",
87 "th",
88 "tr",
89 "uk",
90 "vi"
91 // '\0'
92 };
93 
94 static const char* pInfo[NUM_LANG_WITH_INFO]={
95 "nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;",
96 "nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;",
97 "nplurals=2; plural=(n != 1);",
98 "nplurals=2; plural=(n != 1);",
99 "nplurals=2; plural=(n != 1);",
100 "nplurals=2; plural=(n != 1);",
101 "nplurals=2; plural=(n != 1);",
102 "nplurals=2; plural=(n != 1);",
103 "nplurals=2; plural=(n != 1);",
104 "nplurals=2; plural=(n != 1);",
105 "nplurals=2; plural=(n != 1);",
106 "nplurals=2; plural=(n != 1);",
107 "nplurals=2; plural=(n != 1);",
108 "nplurals=2; plural=(n > 1);",
109 "nplurals=3; plural=n==1 ? 0 : n==2 ? 1 : 2;",
110 "nplurals=2; plural=(n != 1);",
111 "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);",
112 "nplurals=2; plural=(n != 1);",
113 "nplurals=2; plural=(n != 1);",
114 "nplurals=1; plural=0;",
115 "nplurals=1; plural=0;",
116 "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);",
117 "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2);",
118 "nplurals=2; plural=(n != 1);",
119 "nplurals=2; plural=(n != 1);",
120 "nplurals=2; plural=(n != 1);",
121 "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);",
122 "nplurals=2; plural=(n != 1);",
123 "nplurals=2; plural=(n > 1);",
124 "nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2;",
125 "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);",
126 "nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;",
127 "nplurals=4; plural=(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || n%100==4 ? 3 : 0);",
128 "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);",
129 "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);",
130 "nplurals=2; plural=(n != 1);",
131 "nplurals=1; plural=0;",
132 "nplurals=2; plural=(n > 1);",
133 "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);",
134 "nplurals=1; plural=0;"
135 };
136 
137 
138 int numberOfPluralFormsFromHeader(const QString& header)
139 {
140  QRegExp rxplural("Plural-Forms:\\s*nplurals=(.);");
141  if (rxplural.indexIn(header) == -1)
142  return 0;
143  bool ok;
144  int result=rxplural.cap(1).toShort(&ok);
145  return ok?result:0;
146 
147 }
148 
149 int numberOfPluralFormsForLangCode(const QString& langCode)
150 {
151  QString expr=GNUPluralForms(langCode);
152 
153  QRegExp rxplural("nplurals=(.);");
154  if (rxplural.indexIn(expr) == -1)
155  return 0;
156  bool ok;
157  int result=rxplural.cap(1).toShort(&ok);
158  return ok?result:0;
159 
160 }
161 
162 QString GNUPluralForms(const QString& lang)
163 {
164  QByteArray l(lang.toUtf8());
165  int i=NUM_LANG_WITH_INFO;
166  while(--i>=0 && l!=langsWithPInfo[i])
167  ;
168  //if (KDE_ISLIKELY( langsWithPInfo[i]))
169  if (KDE_ISLIKELY( i>=0 ))
170  return QString::fromLatin1(pInfo[i]);
171 
172 
173  //BEGIN alternative
174  // NOTE does this work under M$ OS?
175  qWarning()<<"gonna call msginit";
176  QString def="nplurals=2; plural=n != 1;";
177 
178  QStringList arguments;
179  arguments << "-l" << lang
180  << "-i" << "-"
181  << "-o" << "-"
182  << "--no-translator"
183  << "--no-wrap";
184  QProcess msginit;
185  msginit.start("msginit", arguments);
186 
187  msginit.waitForStarted(5000);
188  if (KDE_ISUNLIKELY( msginit.state()!=QProcess::Running ))
189  {
190  //kWarning()<<"msginit error";
191  return def;
192  }
193 
194  msginit.write(
195  "# SOME DESCRIPTIVE TITLE.\n"
196  "# Copyright (C) YEAR Free Software Foundation, Inc.\n"
197  "# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.\n"
198  "#\n"
199  "#, fuzzy\n"
200  "msgid \"\"\n"
201  "msgstr \"\"\n"
202  "\"Project-Id-Version: PACKAGE VERSION\\n\"\n"
203  "\"POT-Creation-Date: 2002-06-25 03:23+0200\\n\"\n"
204  "\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\"\n"
205  "\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n\"\n"
206  "\"Language-Team: LANGUAGE <LL@li.org>\\n\"\n"
207  "\"Language: LL\\n\"\n"
208  "\"MIME-Version: 1.0\\n\"\n"
209  "\"Content-Type: text/plain; charset=UTF-8\\n\"\n"
210  "\"Content-Transfer-Encoding: ENCODING\\n\"\n"
211 // "\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n"
212  );
213  msginit.closeWriteChannel();
214 
215  if (KDE_ISUNLIKELY( !msginit.waitForFinished(5000) ))
216  {
217  kWarning()<<"msginit error";
218  return def;
219  }
220 
221 
222  QByteArray result = msginit.readAll();
223  int pos = result.indexOf("Plural-Forms: ");
224  if (KDE_ISUNLIKELY( pos==-1 ))
225  {
226  //kWarning()<<"msginit error"<<result;
227  return def;
228  }
229  pos+=14;
230 
231  int end = result.indexOf('"',pos);
232  if (KDE_ISUNLIKELY( pos==-1 ))
233  {
234  //kWarning()<<"msginit error"<<result;
235  return def;
236  }
237 
238  return QString( result.mid(pos,end-pos-2) );
239  //END alternative
240 }
241 
242 
243 void updateHeader(QString& header,
244  QString& comment,
245  QString& langCode,
246  int& numberOfPluralForms,
247  const QString& CatalogProjectId,
248  bool generatedFromDocbook,
249  bool belongsToProject,
250  bool forSaving,
251  QTextCodec* codec)
252 {
253  QStringList headerList(header.split('\n',QString::SkipEmptyParts));
254  QStringList commentList(comment.split('\n',QString::SkipEmptyParts));
255 
256 //BEGIN header itself
257  QStringList::Iterator it,ait;
258  QString temp;
259  QString authorNameEmail;
260 
261  bool found=false;
262  authorNameEmail=Settings::authorName();
263  if (!Settings::authorEmail().isEmpty())
264  authorNameEmail+=(" <"%Settings::authorEmail()%'>');
265  temp="Last-Translator: "%authorNameEmail%"\\n";
266 
267  QRegExp lt("^ *Last-Translator:.*");
268  for ( it = headerList.begin(),found=false; it != headerList.end() && !found; ++it )
269  {
270  if (it->contains(lt))
271  {
272  if (forSaving) *it = temp;
273  found=true;
274  }
275  }
276  if (KDE_ISUNLIKELY( !found ))
277  headerList.append(temp);
278 
279  QString dateTimeString = KDateTime::currentLocalDateTime().toString("%Y-%m-%d %H:%M%z");
280  temp="PO-Revision-Date: "%dateTimeString%"\\n";
281  QRegExp poRevDate("^ *PO-Revision-Date:.*");
282  for ( it = headerList.begin(),found=false; it != headerList.end() && !found; ++it )
283  {
284  found=it->contains(poRevDate);
285  if (found && forSaving) *it = temp;
286  }
287  if (KDE_ISUNLIKELY( !found ))
288  headerList.append(temp);
289 
290  temp="Project-Id-Version: "%CatalogProjectId%"\\n";
291  //temp.replace( "@PACKAGE@", packageName());
292  QRegExp projectIdVer("^ *Project-Id-Version:.*");
293  for ( it = headerList.begin(),found=false; it != headerList.end() && !found; ++it )
294  {
295  found=it->contains(projectIdVer);
296  if (found && it->contains("PACKAGE VERSION"))
297  *it = temp;
298  }
299  if (KDE_ISUNLIKELY( !found ))
300  headerList.append(temp);
301 
302 
303  langCode=Project::instance()->isLoaded()?
304  Project::instance()->langCode():
305  Settings::defaultLangCode();
306  QString language; //initialized with preexisting value or later
307  QString mailingList; //initialized with preexisting value or later
308 
309  static KConfig* allLanguagesConfig=0;
310  if (!allLanguagesConfig)
311  {
312  allLanguagesConfig = new KConfig("all_languages", KConfig::NoGlobals, "locale");
313  allLanguagesConfig->setLocale(QString());
314  }
315  QRegExp langTeamRegExp("^ *Language-Team:.*");
316  for ( it = headerList.begin(),found=false; it != headerList.end() && !found; ++it )
317  {
318  found=it->contains(langTeamRegExp);
319  if (found)
320  {
321  //really parse header
322  QMap<QString,QString> map;
323  foreach (const QString &runningLangCode, KGlobal::locale()->allLanguagesList())
324  {
325  KConfigGroup cg(allLanguagesConfig, runningLangCode);
326  map[cg.readEntry("Name")]=runningLangCode;
327  }
328  if (map.size()<16) //may be just "en_US" and ""
329  kWarning()<<"seems that all_languages file is missing (usually located under /usr/share/locale)";
330 
331  QRegExp re("^ *Language-Team: *(.*) *<([^>]*)>");
332  if (re.indexIn(*it) != -1 )
333  {
334  if (map.contains( re.cap(1).trimmed() ))
335  {
336  language=re.cap(1).trimmed();
337  mailingList=re.cap(2).trimmed();
338  langCode=map.value(language);
339  }
340  }
341 
342  ait=it;
343  }
344  }
345 
346  if (language.isEmpty())
347  {
348  //language=locale.languageCodeToName(d->_langCode);
349  KConfigGroup cg(allLanguagesConfig, langCode);
350  language=cg.readEntry("Name");
351  if (language.isEmpty())
352  language=langCode;
353  }
354 
355  if (mailingList.isEmpty() || belongsToProject)
356  {
357  if (Project::instance()->isLoaded())
358  mailingList=Project::instance()->mailingList();
359  else //if (mailingList.isEmpty())
360  mailingList=Settings::defaultMailingList();
361  }
362 
363 
364 
365  temp="Language-Team: "%language%" <"%mailingList%'>';
366  temp+="\\n";
367  if (KDE_ISLIKELY( found ))
368  (*ait) = temp;
369  else
370  headerList.append(temp);
371 
372  QRegExp langCodeRegExp("^ *Language: *([^ \\\\]*)");
373  temp="Language: "%langCode%"\\n";
374  for ( it = headerList.begin(),found=false; it != headerList.end() && !found; ++it )
375  {
376  found=(langCodeRegExp.indexIn(*it)!=-1);
377  if (found && langCodeRegExp.cap(1).isEmpty())
378  *it=temp;
379  //if (found) qWarning()<<"got explicit lang code:"<<langCodeRegExp.cap(1);
380  }
381  if (KDE_ISUNLIKELY( !found ))
382  headerList.append(temp);
383 
384  temp="Content-Type: text/plain; charset="%codec->name()%"\\n";
385  for ( it = headerList.begin(),found=false; it != headerList.end() && !found; ++it )
386  {
387  found=it->contains(QRegExp("^ *Content-Type:.*"));
388  if (found) *it=temp;
389  }
390  if (KDE_ISUNLIKELY( !found ))
391  headerList.append(temp);
392 
393 
394  found=false;
395  temp="Content-Transfer-Encoding: 8bit\\n";
396 
397  for ( it = headerList.begin(),found=false; it != headerList.end() && !found; ++it )
398  found=it->contains(QRegExp("^ *Content-Transfer-Encoding:.*"));
399  if (!found)
400  headerList.append(temp);
401 
402  // ensure MIME-Version header
403  temp="MIME-Version: 1.0\\n";
404  for ( it = headerList.begin(),found=false; it != headerList.end()&& !found; ++it )
405  {
406  found=it->contains(QRegExp("^ *MIME-Version:"));
407  if (found) *it = temp;
408  }
409  if (KDE_ISUNLIKELY( !found ))
410  headerList.append(temp);
411 
412 
413  //kDebug()<<"testing for GNUPluralForms";
414  // update plural form header
415  for ( it = headerList.begin(),found=false; it != headerList.end()&& !found; ++it )
416  found=it->contains(QRegExp("^ *Plural-Forms:"));
417  if (found)
418  {
419  --it;
420 
421  //kDebug()<<"GNUPluralForms found";
422  int num=numberOfPluralFormsFromHeader(header);
423  if (!num)
424  {
425  if (generatedFromDocbook)
426  num=1;
427  else
428  {
429  kWarning()<<"No plural form info in header, using project-defined one"<<langCode;
430  QString t=GNUPluralForms(langCode);
431  //kWarning()<<"generated: " << t;
432  if ( !t.isEmpty() )
433  {
434  QRegExp pf("^ *Plural-Forms:\\s*nplurals.*\\\\n");
435  pf.setMinimal(true);
436  temp=QString("Plural-Forms: %1\\n").arg(t);
437  it->replace(pf,temp);
438  num=numberOfPluralFormsFromHeader(temp);
439  }
440  else
441  {
442  kWarning()<<"no... smth went wrong :(\ncheck your gettext install";
443  num=2;
444  }
445  }
446  }
447  numberOfPluralForms=num;
448 
449  }
450  else if ( !generatedFromDocbook)
451  {
452  //kDebug()<<"generating GNUPluralForms"<<langCode;
453  QString t= GNUPluralForms(langCode);
454  //kDebug()<<"here it is:";
455  if ( !t.isEmpty() )
456  headerList.append(QString("Plural-Forms: %1\\n").arg(t));
457  }
458 
459  temp="X-Generator: Lokalize %1\\n";
460  temp=temp.arg(LOKALIZE_VERSION);
461 
462  for ( it = headerList.begin(),found=false; it != headerList.end()&& !found; ++it )
463  {
464  found=it->contains(QRegExp("^ *X-Generator:.*"));
465  if (found) *it = temp;
466  }
467  if (KDE_ISUNLIKELY( !found ))
468  headerList.append(temp);
469 
470  //m_header.setMsgstr( headerList.join( "\n" ) );
471  header=headerList.join("\n");
472 //END header itself
473 
474 //BEGIN comment = description, copyrights
475  // U+00A9 is the Copyright sign
476  QRegExp fsfc("^# *Copyright (\\(C\\)|\\x00a9).*Free Software Foundation, Inc");
477  for ( it = commentList.begin(),found=false; it != commentList.end()&&!found; ++it )
478  {
479  found=it->contains( fsfc ) ;
480  if (found)
481  it->replace("YEAR", QDate::currentDate().toString("yyyy"));
482  }
483 /*
484  if( saveOptions.FSFCopyright == ProjectSettingsBase::Update )
485  {
486  //update years
487  QString cy = QDate::currentDate().toString("yyyy");
488  if( !it->contains( QRegExp(cy)) ) // is the year already included?
489  {
490  int index = it->lastIndexOf( QRegExp("[\\d]+[\\d\\-, ]*") );
491  if( index == -1 )
492  {
493  KMessageBox::information(0,i18n("Free Software Foundation Copyright does not contain any year. "
494  "It will not be updated."));
495  } else {
496  it->insert(index+1, QString(", ")+cy);
497  }
498  }
499  }*/
500 #if 0
501  if ( ( !usePrefs || saveOptions.updateDescription )
502  && ( !saveOptions.descriptionString.isEmpty() ) )
503  {
504  temp = "# "+saveOptions.descriptionString;
505  temp.replace( "@PACKAGE@", packageName());
506  temp.replace( "@LANGUAGE@", identityOptions.languageName);
507  temp = temp.trimmed();
508 
509  // The description strings has often buggy variants already in the file, these must be removed
510  QString regexpstr = "^#\\s+" + QRegExp::escape( saveOptions.descriptionString.trimmed() ) + "\\s*$";
511  regexpstr.replace( "@PACKAGE@", ".*" );
512  regexpstr.replace( "@LANGUAGE@", ".*" );
513  //kDebug() << "REGEXPSTR: " << regexpstr;
514  QRegExp regexp ( regexpstr );
515 
516  // The buggy variants exist in English too (of a time before KBabel got a translation for the corresponding language)
517  QRegExp regexpUntranslated ( "^#\\s+translation of .* to .*\\s*$" );
518 
519 
520  kDebug () << "Temp is '" << temp << "'";
521 
522  found=false;
523  bool foundTemplate=false;
524 
525  it = commentList.begin();
526  while ( it != commentList.end() )
527  {
528  kDebug () << "testing '" << (*it) << "'";
529  bool deleteItem = false;
530 
531  if ( (*it) == temp )
532  {
533  kDebug () << "Match ";
534  if ( found )
535  deleteItem = true;
536  else
537  found=true;
538  }
539  else if ( regexp.indexIn( *it ) >= 0 )
540  {
541  // We have a similar (translated) string (from another project or another language (perhaps typos)). Remove it.
542  deleteItem = true;
543  }
544  else if ( regexpUntranslated.indexIn( *it ) >= 0 )
545  {
546  // We have a similar (untranslated) string (from another project or another language (perhaps typos)). Remove it.
547  deleteItem = true;
548  }
549  else if ( (*it) == "# SOME DESCRIPTIVE TITLE." )
550  {
551  // We have the standard title placeholder, remove it
552  deleteItem = true;
553  }
554 
555  if ( deleteItem )
556  it = commentList.erase( it );
557  else
558  ++it;
559  }
560  if (!found) commentList.prepend(temp);
561  }
562 #endif
563  // kDebug() << "HEADER COMMENT: " << commentList;
564 
565  /* if ( (!usePrefs || saveOptions.updateTranslatorCopyright)
566  && ( ! identityOptions->readEntry("authorName","").isEmpty() )
567  && ( ! identityOptions->readEntry("Email","").isEmpty() ) ) // An email address can be used as ersatz of a name
568  {*/
569 // return;
570  QStringList foundAuthors;
571 
572  temp="# "%authorNameEmail%", "%QDate::currentDate().toString("yyyy")%'.';
573 
574  // ### TODO: it would be nice if the entry could start with "COPYRIGHT" and have the "(C)" symbol (both not mandatory)
575  QRegExp regexpAuthorYear( "^#.*(<.+@.+>)?,\\s*([\\d]+[\\d\\-, ]*|YEAR)" );
576  QRegExp regexpYearAlone( "^# , \\d{4}.?\\s*$" );
577  if (commentList.isEmpty())
578  {
579  commentList.append(temp);
580  commentList.append(QString());
581  }
582  else
583  {
584  it = commentList.begin();
585  while ( it != commentList.end() )
586  {
587  bool deleteItem = false;
588  if ( it->indexOf( "copyright", 0, Qt::CaseInsensitive ) != -1 )
589  {
590  // We have a line with a copyright. It should not be moved.
591  }
592  else if ( it->contains( QRegExp("#, *fuzzy") ) )
593  deleteItem = true;
594  else if ( it->contains( regexpYearAlone ) )
595  {
596  // We have found a year number that is preceded by a comma.
597  // That is typical of KBabel 1.10 (and earlier?) when there is neither an author name nor an email
598  // Remove the entry
599  deleteItem = true;
600  }
601  else if ( it->contains( "# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.") )
602  deleteItem = true;
603  else if ( it->contains( "# SOME DESCRIPTIVE TITLE"))
604  deleteItem = true;
605  else if ( it->contains( regexpAuthorYear ) ) // email address followed by year
606  {
607  if ( !foundAuthors.contains( (*it) ) )
608  {
609  // The author line is new (and not a duplicate), so add it to the author line list
610  foundAuthors.append( (*it) );
611  }
612  // Delete also non-duplicated entry, as now all what is needed will be processed in foundAuthors
613  deleteItem = true;
614  }
615 
616  if ( deleteItem )
617  it = commentList.erase( it );
618  else
619  ++it;
620  }
621 
622  if ( !foundAuthors.isEmpty() )
623  {
624  found = false;
625  bool foundAuthor = false;
626 
627  const QString cy = QDate::currentDate().toString("yyyy");
628 
629  ait = foundAuthors.end();
630  for ( it = foundAuthors.begin() ; it!=foundAuthors.end(); ++it )
631  {
632  if ( it->contains(Settings::authorName()) || it->contains(Settings::authorEmail()) )
633  {
634  foundAuthor = true;
635  if ( it->contains( cy ) )
636  found = true;
637  else
638  ait = it;
639  }
640  }
641  if ( !found )
642  {
643  if ( !foundAuthor )
644  foundAuthors.append(temp);
645  else if ( ait != foundAuthors.end() )
646  {
647  //update years
648  const int index = (*ait).lastIndexOf( QRegExp("[\\d]+[\\d\\-, ]*") );
649  if ( index == -1 )
650  (*ait)+=", "%cy;
651  else
652  ait->insert(index+1, ", "%cy);
653  }
654  else
655  kDebug() << "INTERNAL ERROR: author found but iterator dangling!";
656  }
657 
658  }
659  else
660  foundAuthors.append(temp);
661 
662 
663  foreach (QString author, foundAuthors)
664  {
665  // ensure dot at the end of copyright
666  if ( !author.endsWith('.') ) author += '.';
667  commentList.append(author);
668  }
669  }
670 
671  //m_header.setComment( commentList.join( "\n" ) );
672  comment=commentList.join("\n");
673 
674 //END comment = description, copyrights
675 }
676 
project.h
NUM_LANG_WITH_INFO
#define NUM_LANG_WITH_INFO
this data was obtained by running GNUPluralForms() on all languages KDE knows of
Definition: gettextheader.cpp:49
Project::instance
static Project * instance()
Definition: project.cpp:67
ProjectBase::langCode
QString langCode() const
Get LangCode.
Definition: projectbase.h:65
Settings::defaultLangCode
static QString defaultLangCode()
Get DefaultLangCode.
Definition: prefs_lokalize.h:79
Settings::authorEmail
static QString authorEmail()
Get authorEmail.
Definition: prefs_lokalize.h:61
numberOfPluralFormsFromHeader
int numberOfPluralFormsFromHeader(const QString &header)
Definition: gettextheader.cpp:138
langsWithPInfo
static const char * langsWithPInfo[NUM_LANG_WITH_INFO]
Definition: gettextheader.cpp:50
Settings::authorName
static QString authorName()
Get authorName.
Definition: prefs_lokalize.h:25
Settings::defaultMailingList
static QString defaultMailingList()
Get DefaultMailingList.
Definition: prefs_lokalize.h:97
GNUPluralForms
QString GNUPluralForms(const QString &lang)
Definition: gettextheader.cpp:162
LOKALIZE_VERSION
#define LOKALIZE_VERSION
Definition: version.h:11
escape
static QString escape(QString str)
Definition: jobs.cpp:365
ProjectBase::mailingList
QString mailingList() const
Get MailingList.
Definition: projectbase.h:116
gettextheader.h
Project::isLoaded
bool isLoaded() const
Definition: project.h:62
version.h
prefs_lokalize.h
updateHeader
void updateHeader(QString &header, QString &comment, QString &langCode, int &numberOfPluralForms, const QString &CatalogProjectId, bool generatedFromDocbook, bool belongsToProject, bool forSaving, QTextCodec *codec)
Definition: gettextheader.cpp:243
pInfo
static const char * pInfo[NUM_LANG_WITH_INFO]
Definition: gettextheader.cpp:94
numberOfPluralFormsForLangCode
int numberOfPluralFormsForLangCode(const QString &langCode)
Definition: gettextheader.cpp:149
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:03:45 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

lokalize

Skip menu "lokalize"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal