mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 15:28:14 +02:00
Examples: added translation example by Mike Sapsard and wp, bug #25376
git-svn-id: trunk@43571 -
This commit is contained in:
parent
b0287567ee
commit
1994cf3411
20
.gitattributes
vendored
20
.gitattributes
vendored
@ -4875,6 +4875,26 @@ examples/toolbar.lpi svneol=native#text/plain
|
||||
examples/toolbar.pp svneol=native#text/pascal
|
||||
examples/trackbar.lpi svneol=native#text/plain
|
||||
examples/trackbar.pp svneol=native#text/pascal
|
||||
examples/translation/languages/translation_demo.de.po svneol=native#text/plain
|
||||
examples/translation/languages/translation_demo.en.po svneol=native#text/plain
|
||||
examples/translation/languages/translation_demo.es.po svneol=native#text/plain
|
||||
examples/translation/languages/translation_demo.fr.po svneol=native#text/plain
|
||||
examples/translation/languages/translation_demo.he.po svneol=native#text/plain
|
||||
examples/translation/languages/translation_demo.po svneol=native#text/plain
|
||||
examples/translation/languages/translation_demo.ru.po svneol=native#text/plain
|
||||
examples/translation/localizedforms.lfm svneol=native#text/plain
|
||||
examples/translation/localizedforms.lrt svneol=native#text/plain
|
||||
examples/translation/localizedforms.pas svneol=native#text/pascal
|
||||
examples/translation/main.lfm svneol=native#text/plain
|
||||
examples/translation/main.lrt svneol=native#text/plain
|
||||
examples/translation/main.pas svneol=native#text/pascal
|
||||
examples/translation/stringsunit.pas svneol=native#text/pascal
|
||||
examples/translation/translation_demo.lpi svneol=native#text/plain
|
||||
examples/translation/translation_demo.lpr svneol=native#text/pascal
|
||||
examples/translation/translation_demo.res -text
|
||||
examples/translation/unit2.lfm svneol=native#text/plain
|
||||
examples/translation/unit2.lrt svneol=native#text/plain
|
||||
examples/translation/unit2.pas svneol=native#text/pascal
|
||||
examples/trayicon/createbundle.sh svneol=native#text/plain
|
||||
examples/trayicon/frmtest.dfm -text
|
||||
examples/trayicon/frmtest.lfm -text
|
||||
|
147
examples/translation/languages/translation_demo.de.po
Normal file
147
examples/translation/languages/translation_demo.de.po
Normal file
@ -0,0 +1,147 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: Translation_Demo\n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.6.3\n"
|
||||
"Language: de\n"
|
||||
|
||||
#: stringsunit.rsbeer
|
||||
msgctxt "stringsunit.rsbeer"
|
||||
msgid "Beer"
|
||||
msgstr "Bier"
|
||||
|
||||
#: stringsunit.rseight
|
||||
msgid "Eight"
|
||||
msgstr "acht"
|
||||
|
||||
#: stringsunit.rsfive
|
||||
msgid "Five"
|
||||
msgstr "fünf"
|
||||
|
||||
#: stringsunit.rsfour
|
||||
msgid "Four"
|
||||
msgstr "vier"
|
||||
|
||||
#: stringsunit.rsnine
|
||||
msgid "Nine"
|
||||
msgstr "neun"
|
||||
|
||||
#: stringsunit.rsone
|
||||
msgid "One"
|
||||
msgstr "eins"
|
||||
|
||||
#: stringsunit.rsseven
|
||||
msgid "Seven"
|
||||
msgstr "sieben"
|
||||
|
||||
#: stringsunit.rssix
|
||||
msgid "Six"
|
||||
msgstr "sechs"
|
||||
|
||||
#: stringsunit.rssumofselectednumbers
|
||||
msgid "Sum of selected numbers: %s"
|
||||
msgstr "Summe der gewählten Zahlen: %s"
|
||||
|
||||
#: stringsunit.rsthree
|
||||
msgid "Three"
|
||||
msgstr "drei"
|
||||
|
||||
#: stringsunit.rstodayis
|
||||
msgctxt "stringsunit.rstodayis"
|
||||
msgid "Today is %s"
|
||||
msgstr "Heute ist %s."
|
||||
|
||||
#: stringsunit.rstwo
|
||||
msgid "Two"
|
||||
msgstr "zwei"
|
||||
|
||||
#: stringsunit.rswater
|
||||
msgctxt "stringsunit.rswater"
|
||||
msgid "Water"
|
||||
msgstr "Wasser"
|
||||
|
||||
#: stringsunit.rswine
|
||||
msgctxt "stringsunit.rswine"
|
||||
msgid "Wine"
|
||||
msgstr "Wein"
|
||||
|
||||
#: stringsunit.rsyouselected
|
||||
msgctxt "stringsunit.rsyouselected"
|
||||
msgid "You selected %s."
|
||||
msgstr "Sie haben %s gewählt."
|
||||
|
||||
#: stringsunit.rsyouselectedat
|
||||
msgctxt "stringsunit.rsyouselectedat"
|
||||
msgid "You selected %0:s at %1:s."
|
||||
msgstr "Sie haben um %1:s %0:s gewählt."
|
||||
|
||||
#: tform2.caption
|
||||
msgid "Second Form"
|
||||
msgstr "Zweites Formular"
|
||||
|
||||
#: tform2.checkgroup.caption
|
||||
msgctxt "tform2.checkgroup.caption"
|
||||
msgid "Several items"
|
||||
msgstr "Mehrere Einträge"
|
||||
|
||||
#: tform2.groupbox1.caption
|
||||
msgid "Please select"
|
||||
msgstr "Bitte auswählen"
|
||||
|
||||
#: tform2.lblmoney.caption
|
||||
msgid "LblMoney"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lblsum.caption
|
||||
msgid "LblSum"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lbltodayis.caption
|
||||
msgid "LblTodayIs"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.radiogroup.caption
|
||||
msgctxt "tform2.radiogroup.caption"
|
||||
msgid "Single item"
|
||||
msgstr "Ein Eintrag allein"
|
||||
|
||||
#: tlocalizedform.caption
|
||||
msgid "LocalizedForm"
|
||||
msgstr ""
|
||||
|
||||
#: tmainform.button1.caption
|
||||
msgctxt "tmainform.button1.caption"
|
||||
msgid "Open second form"
|
||||
msgstr "Zweites Formular öffnen"
|
||||
|
||||
#: tmainform.button2.caption
|
||||
msgctxt "tmainform.button2.caption"
|
||||
msgid "What did you select?"
|
||||
msgstr "Was haben Sie gewählt?"
|
||||
|
||||
#: tmainform.caption
|
||||
msgctxt "tmainform.caption"
|
||||
msgid "Translation demo"
|
||||
msgstr "Übersetzungsdemo"
|
||||
|
||||
#: tmainform.label1.caption
|
||||
msgctxt "tmainform.label1.caption"
|
||||
msgid "Select language"
|
||||
msgstr "Sprache auswählen"
|
||||
|
||||
#: tmainform.lblcurrentselection.caption
|
||||
msgctxt "tmainform.lblcurrentselection.caption"
|
||||
msgid "No drink selected."
|
||||
msgstr "Kein Getränk ausgewählt."
|
||||
|
||||
#: tmainform.rgdrinks.caption
|
||||
msgctxt "tmainform.rgdrinks.caption"
|
||||
msgid "Please select a drink"
|
||||
msgstr "Bitte ein Getränk auswählen"
|
||||
|
147
examples/translation/languages/translation_demo.en.po
Normal file
147
examples/translation/languages/translation_demo.en.po
Normal file
@ -0,0 +1,147 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: Translation_Demo\n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.6.3\n"
|
||||
"Language: en\n"
|
||||
|
||||
#: stringsunit.rsbeer
|
||||
msgctxt "stringsunit.rsbeer"
|
||||
msgid "Beer"
|
||||
msgstr "beer"
|
||||
|
||||
#: stringsunit.rseight
|
||||
msgid "Eight"
|
||||
msgstr "eight"
|
||||
|
||||
#: stringsunit.rsfive
|
||||
msgid "Five"
|
||||
msgstr "five"
|
||||
|
||||
#: stringsunit.rsfour
|
||||
msgid "Four"
|
||||
msgstr "four"
|
||||
|
||||
#: stringsunit.rsnine
|
||||
msgid "Nine"
|
||||
msgstr "nine"
|
||||
|
||||
#: stringsunit.rsone
|
||||
msgid "One"
|
||||
msgstr "one"
|
||||
|
||||
#: stringsunit.rsseven
|
||||
msgid "Seven"
|
||||
msgstr "seven"
|
||||
|
||||
#: stringsunit.rssix
|
||||
msgid "Six"
|
||||
msgstr "six"
|
||||
|
||||
#: stringsunit.rssumofselectednumbers
|
||||
msgid "Sum of selected numbers: %s"
|
||||
msgstr "Sum of selected numbers: %s"
|
||||
|
||||
#: stringsunit.rsthree
|
||||
msgid "Three"
|
||||
msgstr "three"
|
||||
|
||||
#: stringsunit.rstodayis
|
||||
msgctxt "stringsunit.rstodayis"
|
||||
msgid "Today is %s"
|
||||
msgstr "Today is %s"
|
||||
|
||||
#: stringsunit.rstwo
|
||||
msgid "Two"
|
||||
msgstr "two"
|
||||
|
||||
#: stringsunit.rswater
|
||||
msgctxt "stringsunit.rswater"
|
||||
msgid "Water"
|
||||
msgstr "water"
|
||||
|
||||
#: stringsunit.rswine
|
||||
msgctxt "stringsunit.rswine"
|
||||
msgid "Wine"
|
||||
msgstr "wine"
|
||||
|
||||
#: stringsunit.rsyouselected
|
||||
msgctxt "stringsunit.rsyouselected"
|
||||
msgid "You selected %s."
|
||||
msgstr "You selected %s."
|
||||
|
||||
#: stringsunit.rsyouselectedat
|
||||
msgctxt "stringsunit.rsyouselectedat"
|
||||
msgid "You selected %0:s at %1:s."
|
||||
msgstr "You selected %0:s at %1:s."
|
||||
|
||||
#: tform2.caption
|
||||
msgid "Second Form"
|
||||
msgstr "Second Form"
|
||||
|
||||
#: tform2.checkgroup.caption
|
||||
msgctxt "tform2.checkgroup.caption"
|
||||
msgid "Several items"
|
||||
msgstr "Several items"
|
||||
|
||||
#: tform2.groupbox1.caption
|
||||
msgid "Please select"
|
||||
msgstr "Please select"
|
||||
|
||||
#: tform2.lblmoney.caption
|
||||
msgid "LblMoney"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lblsum.caption
|
||||
msgid "LblSum"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lbltodayis.caption
|
||||
msgid "LblTodayIs"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.radiogroup.caption
|
||||
msgctxt "tform2.radiogroup.caption"
|
||||
msgid "Single item"
|
||||
msgstr "Single item"
|
||||
|
||||
#: tlocalizedform.caption
|
||||
msgid "LocalizedForm"
|
||||
msgstr ""
|
||||
|
||||
#: tmainform.button1.caption
|
||||
msgctxt "tmainform.button1.caption"
|
||||
msgid "Open second form"
|
||||
msgstr "Open second form"
|
||||
|
||||
#: tmainform.button2.caption
|
||||
msgctxt "tmainform.button2.caption"
|
||||
msgid "What did you select?"
|
||||
msgstr "What did you select?"
|
||||
|
||||
#: tmainform.caption
|
||||
msgctxt "tmainform.caption"
|
||||
msgid "Translation demo"
|
||||
msgstr "Translation demo"
|
||||
|
||||
#: tmainform.label1.caption
|
||||
msgctxt "tmainform.label1.caption"
|
||||
msgid "Select language"
|
||||
msgstr "Select language"
|
||||
|
||||
#: tmainform.lblcurrentselection.caption
|
||||
msgctxt "tmainform.lblcurrentselection.caption"
|
||||
msgid "No drink selected."
|
||||
msgstr "No drink selected."
|
||||
|
||||
#: tmainform.rgdrinks.caption
|
||||
msgctxt "tmainform.rgdrinks.caption"
|
||||
msgid "Please select a drink"
|
||||
msgstr "Please select a drink"
|
||||
|
147
examples/translation/languages/translation_demo.es.po
Normal file
147
examples/translation/languages/translation_demo.es.po
Normal file
@ -0,0 +1,147 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: translation_demo\n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.6.3\n"
|
||||
"Language: es\n"
|
||||
|
||||
#: stringsunit.rsbeer
|
||||
msgctxt "stringsunit.rsbeer"
|
||||
msgid "Beer"
|
||||
msgstr "cerveza"
|
||||
|
||||
#: stringsunit.rseight
|
||||
msgid "Eight"
|
||||
msgstr "ocho"
|
||||
|
||||
#: stringsunit.rsfive
|
||||
msgid "Five"
|
||||
msgstr "cinco"
|
||||
|
||||
#: stringsunit.rsfour
|
||||
msgid "Four"
|
||||
msgstr "cuatro"
|
||||
|
||||
#: stringsunit.rsnine
|
||||
msgid "Nine"
|
||||
msgstr "nueve"
|
||||
|
||||
#: stringsunit.rsone
|
||||
msgid "One"
|
||||
msgstr "uno"
|
||||
|
||||
#: stringsunit.rsseven
|
||||
msgid "Seven"
|
||||
msgstr "siete"
|
||||
|
||||
#: stringsunit.rssix
|
||||
msgid "Six"
|
||||
msgstr "seis"
|
||||
|
||||
#: stringsunit.rssumofselectednumbers
|
||||
msgid "Sum of selected numbers: %s"
|
||||
msgstr "Suma de números seleccionados: %s"
|
||||
|
||||
#: stringsunit.rsthree
|
||||
msgid "Three"
|
||||
msgstr "tres"
|
||||
|
||||
#: stringsunit.rstodayis
|
||||
msgctxt "stringsunit.rstodayis"
|
||||
msgid "Today is %s"
|
||||
msgstr "Hoy es %s."
|
||||
|
||||
#: stringsunit.rstwo
|
||||
msgid "Two"
|
||||
msgstr "dos"
|
||||
|
||||
#: stringsunit.rswater
|
||||
msgctxt "stringsunit.rswater"
|
||||
msgid "Water"
|
||||
msgstr "agua"
|
||||
|
||||
#: stringsunit.rswine
|
||||
msgctxt "stringsunit.rswine"
|
||||
msgid "Wine"
|
||||
msgstr "vino"
|
||||
|
||||
#: stringsunit.rsyouselected
|
||||
msgctxt "stringsunit.rsyouselected"
|
||||
msgid "You selected %s."
|
||||
msgstr "Ha seleccionado %s."
|
||||
|
||||
#: stringsunit.rsyouselectedat
|
||||
msgctxt "stringsunit.rsyouselectedat"
|
||||
msgid "You selected %0:s at %1:s."
|
||||
msgstr "A las %1:s usted ha elegido %0:s."
|
||||
|
||||
#: tform2.caption
|
||||
msgid "Second Form"
|
||||
msgstr "Segunda Forma"
|
||||
|
||||
#: tform2.checkgroup.caption
|
||||
msgctxt "tform2.checkgroup.caption"
|
||||
msgid "Several items"
|
||||
msgstr "Varios artículos"
|
||||
|
||||
#: tform2.groupbox1.caption
|
||||
msgid "Please select"
|
||||
msgstr "Por favor seleccione"
|
||||
|
||||
#: tform2.lblmoney.caption
|
||||
msgid "LblMoney"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lblsum.caption
|
||||
msgid "LblSum"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lbltodayis.caption
|
||||
msgid "LblTodayIs"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.radiogroup.caption
|
||||
msgctxt "tform2.radiogroup.caption"
|
||||
msgid "Single item"
|
||||
msgstr "Un solo artículo"
|
||||
|
||||
#: tlocalizedform.caption
|
||||
msgid "LocalizedForm"
|
||||
msgstr ""
|
||||
|
||||
#: tmainform.button1.caption
|
||||
msgctxt "tmainform.button1.caption"
|
||||
msgid "Open second form"
|
||||
msgstr "La apertura de una segunda forma"
|
||||
|
||||
#: tmainform.button2.caption
|
||||
msgctxt "tmainform.button2.caption"
|
||||
msgid "What did you select?"
|
||||
msgstr "¿Qué es lo que seleccione?"
|
||||
|
||||
#: tmainform.caption
|
||||
msgctxt "tmainform.caption"
|
||||
msgid "Translation demo"
|
||||
msgstr "Demostración Traducción"
|
||||
|
||||
#: tmainform.label1.caption
|
||||
msgctxt "tmainform.label1.caption"
|
||||
msgid "Select language"
|
||||
msgstr "Seleccionar idioma"
|
||||
|
||||
#: tmainform.lblcurrentselection.caption
|
||||
msgctxt "tmainform.lblcurrentselection.caption"
|
||||
msgid "No drink selected."
|
||||
msgstr "Ninguna bebida seleccionada."
|
||||
|
||||
#: tmainform.rgdrinks.caption
|
||||
msgctxt "tmainform.rgdrinks.caption"
|
||||
msgid "Please select a drink"
|
||||
msgstr "Por favor seleccione una copa"
|
||||
|
147
examples/translation/languages/translation_demo.fr.po
Normal file
147
examples/translation/languages/translation_demo.fr.po
Normal file
@ -0,0 +1,147 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: Translation_Demo\n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.6.3\n"
|
||||
"Language: fr\n"
|
||||
|
||||
#: stringsunit.rsbeer
|
||||
msgctxt "stringsunit.rsbeer"
|
||||
msgid "Beer"
|
||||
msgstr "bière"
|
||||
|
||||
#: stringsunit.rseight
|
||||
msgid "Eight"
|
||||
msgstr "huit"
|
||||
|
||||
#: stringsunit.rsfive
|
||||
msgid "Five"
|
||||
msgstr "cinq"
|
||||
|
||||
#: stringsunit.rsfour
|
||||
msgid "Four"
|
||||
msgstr "quatre"
|
||||
|
||||
#: stringsunit.rsnine
|
||||
msgid "Nine"
|
||||
msgstr "neuf"
|
||||
|
||||
#: stringsunit.rsone
|
||||
msgid "One"
|
||||
msgstr "un"
|
||||
|
||||
#: stringsunit.rsseven
|
||||
msgid "Seven"
|
||||
msgstr "sept"
|
||||
|
||||
#: stringsunit.rssix
|
||||
msgid "Six"
|
||||
msgstr "six"
|
||||
|
||||
#: stringsunit.rssumofselectednumbers
|
||||
msgid "Sum of selected numbers: %s"
|
||||
msgstr "Somme des nombres choisis: %s"
|
||||
|
||||
#: stringsunit.rsthree
|
||||
msgid "Three"
|
||||
msgstr "trois"
|
||||
|
||||
#: stringsunit.rstodayis
|
||||
msgctxt "stringsunit.rstodayis"
|
||||
msgid "Today is %s"
|
||||
msgstr "Aujourd'hui est %s."
|
||||
|
||||
#: stringsunit.rstwo
|
||||
msgid "Two"
|
||||
msgstr "deux"
|
||||
|
||||
#: stringsunit.rswater
|
||||
msgctxt "stringsunit.rswater"
|
||||
msgid "Water"
|
||||
msgstr "eau"
|
||||
|
||||
#: stringsunit.rswine
|
||||
msgctxt "stringsunit.rswine"
|
||||
msgid "Wine"
|
||||
msgstr "vin"
|
||||
|
||||
#: stringsunit.rsyouselected
|
||||
msgctxt "stringsunit.rsyouselected"
|
||||
msgid "You selected %s."
|
||||
msgstr "Vous avez choisi %s."
|
||||
|
||||
#: stringsunit.rsyouselectedat
|
||||
msgctxt "stringsunit.rsyouselectedat"
|
||||
msgid "You selected %0:s at %1:s."
|
||||
msgstr "A %1:s, vous avez choisi %0:s."
|
||||
|
||||
#: tform2.caption
|
||||
msgid "Second Form"
|
||||
msgstr "Deuxième forme"
|
||||
|
||||
#: tform2.checkgroup.caption
|
||||
msgctxt "tform2.checkgroup.caption"
|
||||
msgid "Several items"
|
||||
msgstr "Plusieurs articles"
|
||||
|
||||
#: tform2.groupbox1.caption
|
||||
msgid "Please select"
|
||||
msgstr "S'il vous plaît sélectionnez"
|
||||
|
||||
#: tform2.lblmoney.caption
|
||||
msgid "LblMoney"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lblsum.caption
|
||||
msgid "LblSum"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lbltodayis.caption
|
||||
msgid "LblTodayIs"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.radiogroup.caption
|
||||
msgctxt "tform2.radiogroup.caption"
|
||||
msgid "Single item"
|
||||
msgstr "Un seul article"
|
||||
|
||||
#: tlocalizedform.caption
|
||||
msgid "LocalizedForm"
|
||||
msgstr ""
|
||||
|
||||
#: tmainform.button1.caption
|
||||
msgctxt "tmainform.button1.caption"
|
||||
msgid "Open second form"
|
||||
msgstr "Ouverte deuxième forme "
|
||||
|
||||
#: tmainform.button2.caption
|
||||
msgctxt "tmainform.button2.caption"
|
||||
msgid "What did you select?"
|
||||
msgstr "Qu'avez-vous choisi?"
|
||||
|
||||
#: tmainform.caption
|
||||
msgctxt "tmainform.caption"
|
||||
msgid "Translation demo"
|
||||
msgstr "Démo de traduction"
|
||||
|
||||
#: tmainform.label1.caption
|
||||
msgctxt "tmainform.label1.caption"
|
||||
msgid "Select language"
|
||||
msgstr "Choisir la langue"
|
||||
|
||||
#: tmainform.lblcurrentselection.caption
|
||||
msgctxt "tmainform.lblcurrentselection.caption"
|
||||
msgid "No drink selected."
|
||||
msgstr "Aucune boisson est sélectionné."
|
||||
|
||||
#: tmainform.rgdrinks.caption
|
||||
msgctxt "tmainform.rgdrinks.caption"
|
||||
msgid "Please select a drink"
|
||||
msgstr "S'il vous plaît sélectionner un verre"
|
||||
|
147
examples/translation/languages/translation_demo.he.po
Normal file
147
examples/translation/languages/translation_demo.he.po
Normal file
@ -0,0 +1,147 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: Translation_Project\n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: he\n"
|
||||
"X-Generator: Poedit 1.6.3\n"
|
||||
|
||||
#: stringsunit.rsbeer
|
||||
msgctxt "stringsunit.rsbeer"
|
||||
msgid "Beer"
|
||||
msgstr "בירה"
|
||||
|
||||
#: stringsunit.rseight
|
||||
msgid "Eight"
|
||||
msgstr "שמונה"
|
||||
|
||||
#: stringsunit.rsfive
|
||||
msgid "Five"
|
||||
msgstr "חמש"
|
||||
|
||||
#: stringsunit.rsfour
|
||||
msgid "Four"
|
||||
msgstr "ארבעה"
|
||||
|
||||
#: stringsunit.rsnine
|
||||
msgid "Nine"
|
||||
msgstr "תשע"
|
||||
|
||||
#: stringsunit.rsone
|
||||
msgid "One"
|
||||
msgstr "אחד"
|
||||
|
||||
#: stringsunit.rsseven
|
||||
msgid "Seven"
|
||||
msgstr "שבע"
|
||||
|
||||
#: stringsunit.rssix
|
||||
msgid "Six"
|
||||
msgstr "שש"
|
||||
|
||||
#: stringsunit.rssumofselectednumbers
|
||||
msgid "Sum of selected numbers: %s"
|
||||
msgstr "סכום של מספרים שנבחרו: %s"
|
||||
|
||||
#: stringsunit.rsthree
|
||||
msgid "Three"
|
||||
msgstr "שלוש"
|
||||
|
||||
#: stringsunit.rstodayis
|
||||
msgctxt "stringsunit.rstodayis"
|
||||
msgid "Today is %s"
|
||||
msgstr "היום הוא %s"
|
||||
|
||||
#: stringsunit.rstwo
|
||||
msgid "Two"
|
||||
msgstr "שנים"
|
||||
|
||||
#: stringsunit.rswater
|
||||
msgctxt "stringsunit.rswater"
|
||||
msgid "Water"
|
||||
msgstr "מים"
|
||||
|
||||
#: stringsunit.rswine
|
||||
msgctxt "stringsunit.rswine"
|
||||
msgid "Wine"
|
||||
msgstr "יין"
|
||||
|
||||
#: stringsunit.rsyouselected
|
||||
msgctxt "stringsunit.rsyouselected"
|
||||
msgid "You selected %s."
|
||||
msgstr "בחרת %s."
|
||||
|
||||
#: stringsunit.rsyouselectedat
|
||||
msgctxt "stringsunit.rsyouselectedat"
|
||||
msgid "You selected %0:s at %1:s."
|
||||
msgstr "You selected %0:s at %1:s."
|
||||
|
||||
#: tform2.caption
|
||||
msgid "Second Form"
|
||||
msgstr "טופס שני"
|
||||
|
||||
#: tform2.checkgroup.caption
|
||||
msgctxt "tform2.checkgroup.caption"
|
||||
msgid "Several items"
|
||||
msgstr "מספר פריטים"
|
||||
|
||||
#: tform2.groupbox1.caption
|
||||
msgid "Please select"
|
||||
msgstr "אנא בחר"
|
||||
|
||||
#: tform2.lblmoney.caption
|
||||
msgid "LblMoney"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lblsum.caption
|
||||
msgid "LblSum"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lbltodayis.caption
|
||||
msgid "LblTodayIs"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.radiogroup.caption
|
||||
msgctxt "tform2.radiogroup.caption"
|
||||
msgid "Single item"
|
||||
msgstr "פריט בודד"
|
||||
|
||||
#: tlocalizedform.caption
|
||||
msgid "LocalizedForm"
|
||||
msgstr ""
|
||||
|
||||
#: tmainform.button1.caption
|
||||
msgctxt "TMAINFORM.BUTTON1.CAPTION"
|
||||
msgid "Open second form"
|
||||
msgstr "טופס שני פתוח"
|
||||
|
||||
#: tmainform.button2.caption
|
||||
msgctxt "TMAINFORM.BUTTON2.CAPTION"
|
||||
msgid "What did you select?"
|
||||
msgstr "מה אתה בוחר?"
|
||||
|
||||
#: tmainform.caption
|
||||
msgctxt "TMAINFORM.CAPTION"
|
||||
msgid "Translation demo"
|
||||
msgstr "הדגמת תרגום"
|
||||
|
||||
#: tmainform.label1.caption
|
||||
msgctxt "TMAINFORM.LABEL1.CAPTION"
|
||||
msgid "Select language"
|
||||
msgstr "בחר שפה"
|
||||
|
||||
#: tmainform.lblcurrentselection.caption
|
||||
msgctxt "TMAINFORM.LBLCURRENTSELECTION.CAPTION"
|
||||
msgid "No drink selected."
|
||||
msgstr "לא דחוף שנבחר"
|
||||
|
||||
#: tmainform.rgdrinks.caption
|
||||
msgctxt "TMAINFORM.RGDRINKS.CAPTION"
|
||||
msgid "Please select a drink"
|
||||
msgstr "אנא בחר משקה"
|
||||
|
137
examples/translation/languages/translation_demo.po
Normal file
137
examples/translation/languages/translation_demo.po
Normal file
@ -0,0 +1,137 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||
|
||||
#: stringsunit.rsbeer
|
||||
msgctxt "stringsunit.rsbeer"
|
||||
msgid "Beer"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rseight
|
||||
msgid "Eight"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rsfive
|
||||
msgid "Five"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rsfour
|
||||
msgid "Four"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rsnine
|
||||
msgid "Nine"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rsone
|
||||
msgid "One"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rsseven
|
||||
msgid "Seven"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rssix
|
||||
msgid "Six"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rssumofselectednumbers
|
||||
msgid "Sum of selected numbers: %s"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rsthree
|
||||
msgid "Three"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rstodayis
|
||||
msgctxt "stringsunit.rstodayis"
|
||||
msgid "Today is %s"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rstwo
|
||||
msgid "Two"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rswater
|
||||
msgctxt "stringsunit.rswater"
|
||||
msgid "Water"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rswine
|
||||
msgctxt "stringsunit.rswine"
|
||||
msgid "Wine"
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rsyouselected
|
||||
msgctxt "stringsunit.rsyouselected"
|
||||
msgid "You selected %s."
|
||||
msgstr ""
|
||||
|
||||
#: stringsunit.rsyouselectedat
|
||||
msgctxt "stringsunit.rsyouselectedat"
|
||||
msgid "You selected %0:s at %1:s."
|
||||
msgstr ""
|
||||
|
||||
#: tform2.caption
|
||||
msgid "Second Form"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.checkgroup.caption
|
||||
msgctxt "TFORM2.CHECKGROUP.CAPTION"
|
||||
msgid "Several items"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.groupbox1.caption
|
||||
msgid "Please select"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lblmoney.caption
|
||||
msgid "LblMoney"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lblsum.caption
|
||||
msgid "LblSum"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lbltodayis.caption
|
||||
msgid "LblTodayIs"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.radiogroup.caption
|
||||
msgctxt "TFORM2.RADIOGROUP.CAPTION"
|
||||
msgid "Single item"
|
||||
msgstr ""
|
||||
|
||||
#: tlocalizedform.caption
|
||||
msgid "LocalizedForm"
|
||||
msgstr ""
|
||||
|
||||
#: tmainform.button1.caption
|
||||
msgctxt "TMAINFORM.BUTTON1.CAPTION"
|
||||
msgid "Open second form"
|
||||
msgstr ""
|
||||
|
||||
#: tmainform.button2.caption
|
||||
msgctxt "TMAINFORM.BUTTON2.CAPTION"
|
||||
msgid "What did you select?"
|
||||
msgstr ""
|
||||
|
||||
#: tmainform.caption
|
||||
msgctxt "TMAINFORM.CAPTION"
|
||||
msgid "Translation demo"
|
||||
msgstr ""
|
||||
|
||||
#: tmainform.label1.caption
|
||||
msgctxt "TMAINFORM.LABEL1.CAPTION"
|
||||
msgid "Select language"
|
||||
msgstr ""
|
||||
|
||||
#: tmainform.lblcurrentselection.caption
|
||||
msgctxt "TMAINFORM.LBLCURRENTSELECTION.CAPTION"
|
||||
msgid "No drink selected."
|
||||
msgstr ""
|
||||
|
||||
#: tmainform.rgdrinks.caption
|
||||
msgctxt "TMAINFORM.RGDRINKS.CAPTION"
|
||||
msgid "Please select a drink"
|
||||
msgstr ""
|
||||
|
145
examples/translation/languages/translation_demo.ru.po
Normal file
145
examples/translation/languages/translation_demo.ru.po
Normal file
@ -0,0 +1,145 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: Maxim Ganetsky <maxkill@mail.ru>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: stringsunit.rsbeer
|
||||
msgctxt "stringsunit.rsbeer"
|
||||
msgid "Beer"
|
||||
msgstr "Пиво"
|
||||
|
||||
#: stringsunit.rseight
|
||||
msgid "Eight"
|
||||
msgstr "восемь"
|
||||
|
||||
#: stringsunit.rsfive
|
||||
msgid "Five"
|
||||
msgstr "пять"
|
||||
|
||||
#: stringsunit.rsfour
|
||||
msgid "Four"
|
||||
msgstr "четыре"
|
||||
|
||||
#: stringsunit.rsnine
|
||||
msgid "Nine"
|
||||
msgstr "девять"
|
||||
|
||||
#: stringsunit.rsone
|
||||
msgid "One"
|
||||
msgstr "один"
|
||||
|
||||
#: stringsunit.rsseven
|
||||
msgid "Seven"
|
||||
msgstr "семь"
|
||||
|
||||
#: stringsunit.rssix
|
||||
msgid "Six"
|
||||
msgstr "шесть"
|
||||
|
||||
#: stringsunit.rssumofselectednumbers
|
||||
msgid "Sum of selected numbers: %s"
|
||||
msgstr "Сумма выбранных чисел: %s"
|
||||
|
||||
#: stringsunit.rsthree
|
||||
msgid "Three"
|
||||
msgstr "три"
|
||||
|
||||
#: stringsunit.rstodayis
|
||||
msgctxt "stringsunit.rstodayis"
|
||||
msgid "Today is %s"
|
||||
msgstr "Сегодня: %s"
|
||||
|
||||
#: stringsunit.rstwo
|
||||
msgid "Two"
|
||||
msgstr "два"
|
||||
|
||||
#: stringsunit.rswater
|
||||
msgctxt "stringsunit.rswater"
|
||||
msgid "Water"
|
||||
msgstr "Вода"
|
||||
|
||||
#: stringsunit.rswine
|
||||
msgctxt "stringsunit.rswine"
|
||||
msgid "Wine"
|
||||
msgstr "Вино"
|
||||
|
||||
#: stringsunit.rsyouselected
|
||||
msgctxt "stringsunit.rsyouselected"
|
||||
msgid "You selected %s."
|
||||
msgstr "Ваш выбор: %s."
|
||||
|
||||
#: stringsunit.rsyouselectedat
|
||||
msgctxt "stringsunit.rsyouselectedat"
|
||||
msgid "You selected %0:s at %1:s."
|
||||
msgstr "Ваш выбор: %0:s в %1:s."
|
||||
|
||||
#: tform2.caption
|
||||
msgid "Second Form"
|
||||
msgstr "Вторая форма"
|
||||
|
||||
#: tform2.checkgroup.caption
|
||||
msgctxt "TFORM2.CHECKGROUP.CAPTION"
|
||||
msgid "Several items"
|
||||
msgstr "Несколько чисел"
|
||||
|
||||
#: tform2.groupbox1.caption
|
||||
msgid "Please select"
|
||||
msgstr "Выберите"
|
||||
|
||||
#: tform2.lblmoney.caption
|
||||
msgid "LblMoney"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lblsum.caption
|
||||
msgid "LblSum"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.lbltodayis.caption
|
||||
msgid "LblTodayIs"
|
||||
msgstr ""
|
||||
|
||||
#: tform2.radiogroup.caption
|
||||
msgctxt "TFORM2.RADIOGROUP.CAPTION"
|
||||
msgid "Single item"
|
||||
msgstr "Одно число"
|
||||
|
||||
#: tlocalizedform.caption
|
||||
msgid "LocalizedForm"
|
||||
msgstr ""
|
||||
|
||||
#: tmainform.button1.caption
|
||||
msgctxt "TMAINFORM.BUTTON1.CAPTION"
|
||||
msgid "Open second form"
|
||||
msgstr "Открыть вторую форму"
|
||||
|
||||
#: tmainform.button2.caption
|
||||
msgctxt "TMAINFORM.BUTTON2.CAPTION"
|
||||
msgid "What did you select?"
|
||||
msgstr "Что выбрано?"
|
||||
|
||||
#: tmainform.caption
|
||||
msgctxt "TMAINFORM.CAPTION"
|
||||
msgid "Translation demo"
|
||||
msgstr "Демонстрация перевода"
|
||||
|
||||
#: tmainform.label1.caption
|
||||
msgctxt "TMAINFORM.LABEL1.CAPTION"
|
||||
msgid "Select language"
|
||||
msgstr "Выберите язык"
|
||||
|
||||
#: tmainform.lblcurrentselection.caption
|
||||
msgctxt "TMAINFORM.LBLCURRENTSELECTION.CAPTION"
|
||||
msgid "No drink selected."
|
||||
msgstr "Напиток не выбран."
|
||||
|
||||
#: tmainform.rgdrinks.caption
|
||||
msgctxt "TMAINFORM.RGDRINKS.CAPTION"
|
||||
msgid "Please select a drink"
|
||||
msgstr "Выберите напиток"
|
||||
|
8
examples/translation/localizedforms.lfm
Normal file
8
examples/translation/localizedforms.lfm
Normal file
@ -0,0 +1,8 @@
|
||||
object LocalizedForm: TLocalizedForm
|
||||
Left = 447
|
||||
Height = 240
|
||||
Top = 238
|
||||
Width = 320
|
||||
Caption = 'LocalizedForm'
|
||||
LCLVersion = '1.3'
|
||||
end
|
1
examples/translation/localizedforms.lrt
Normal file
1
examples/translation/localizedforms.lrt
Normal file
@ -0,0 +1 @@
|
||||
TLOCALIZEDFORM.CAPTION=LocalizedForm
|
238
examples/translation/localizedforms.pas
Normal file
238
examples/translation/localizedforms.pas
Normal file
@ -0,0 +1,238 @@
|
||||
{ This form can be the ancestor of other forms. It is suitable for changing
|
||||
languages at run-time. It provides the virtual method "UpdateTranslation"
|
||||
which must be overridden by each inherited form in order to update the
|
||||
translation of strings that are not automatically translated by
|
||||
DefaultTranslator (e.g. strings built up by means of Format statements).
|
||||
|
||||
The unit contains also a procedure UpdateFormatSettings which adapts the
|
||||
format settings to the newly selected language, as well as UpdateBiDiMode
|
||||
which enable right-to-left mode as it is used in the Middle East (not perfect,
|
||||
though...) }
|
||||
|
||||
unit LocalizedForms;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs;
|
||||
|
||||
type
|
||||
TLocalizedForm = class(TForm)
|
||||
protected
|
||||
procedure UpdateTranslation(ALang: String); virtual;
|
||||
public
|
||||
procedure FlipChildren(AllLevels: Boolean); override;
|
||||
end;
|
||||
|
||||
var
|
||||
LocalizedForm: TLocalizedForm;
|
||||
CurrentLang: String = '';
|
||||
CodePage: String = '';
|
||||
|
||||
procedure UpdateBiDiMode(ALang: String);
|
||||
procedure UpdateFormatSettings(ALang: String); // Windows only!
|
||||
|
||||
// Utility functions for Windows only
|
||||
function GetFullLangCodeFromLCID(LCID: Integer): String;
|
||||
function GetLangCodeFromLCID(LCID: Integer): String;
|
||||
function GetLCIDFromLangCode(ALang: String): Integer;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
{$IFDEF MSWINDOWS}
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
ExtCtrls;
|
||||
|
||||
|
||||
{ Local procedures }
|
||||
|
||||
function GetLocaleStr(LCID, LT: Longint; const Def: string): ShortString;
|
||||
// borrowed from SysUtils
|
||||
var
|
||||
L: Integer;
|
||||
Buf: array[0..255] of Char;
|
||||
begin
|
||||
L := GetLocaleInfo(LCID, LT, Buf, SizeOf(Buf));
|
||||
if L > 0 then
|
||||
SetString(Result, @Buf[0], L - 1)
|
||||
else
|
||||
Result := Def;
|
||||
end;
|
||||
|
||||
|
||||
{ Utility procedures }
|
||||
|
||||
{ This is how to convert LCID to language code like 'de', 'en', etc.
|
||||
Works only for Windows.
|
||||
See also: GetFullLangCode}
|
||||
function GetLangCodeFromLCID(LCID: Integer): String;
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
language: PAnsiChar;
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}
|
||||
language := StrAlloc(255);
|
||||
try
|
||||
GetLocaleInfoA(LCID, LOCALE_SISO639LANGNAME, PAnsiChar(language), 255);
|
||||
Result := language;
|
||||
finally
|
||||
StrDispose(language);
|
||||
end;
|
||||
{$ELSE}
|
||||
Result := '';
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{ This is how to convert LCID to language code like 'de_DE', 'en_US', etc.
|
||||
The first two characters are the country, the last two are the region.
|
||||
Works only for Windows.
|
||||
See: http://stackoverflow.com/questions/1192361/how-to-convert-microsoft-locale-id-lcid-into-language-code-or-locale-object-in/1192856#1192856
|
||||
or http://delphi.cjcsoft.net/viewthread.php?tid=45881
|
||||
or http://msdn.microsoft.com/en-us/library/dd318101%28VS.85%29.aspx }
|
||||
function GetFullLangCodeFromLCID(LCID: Integer): String;
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
language, country: PAnsiChar;
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}
|
||||
language := StrAlloc(255);
|
||||
country := StrAlloc(255);
|
||||
try
|
||||
GetLocaleInfoA(LCID, LOCALE_SISO639LANGNAME, PAnsiChar(language), 255);
|
||||
GetLocaleInfoA(LCID, LOCALE_SISO3166CTRYNAME, PAnsiChar(country), 255);
|
||||
Result := language + '_' + country;
|
||||
finally
|
||||
StrDispose(country);
|
||||
StrDispose(language);
|
||||
end;
|
||||
{$ELSE}
|
||||
Result := '';
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure UpdateBiDiMode(ALang: String);
|
||||
begin
|
||||
if Application.IsRTLLang(ALang) then
|
||||
Application.BidiMode := bdRightToLeft
|
||||
else
|
||||
Application.BiDiMode := bdLeftToRight;
|
||||
end;
|
||||
|
||||
{ This function determines the LCID from the language code.
|
||||
Works only for Windows. }
|
||||
function GetLCIDFromLangCode(ALang: String): Integer;
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}
|
||||
case lowercase(ALang) of
|
||||
'ar' : Result := $0401; // Arabic
|
||||
'bg' : Result := $0403; // Bulgarian
|
||||
'ca' : Result := $0403; // Catalan
|
||||
'cs' : Result := $0405; // Czech
|
||||
'de' : Result := $0407; // German
|
||||
'en' : Result := $0409; // English (US)
|
||||
'es' : Result := $040A; // Spanisch
|
||||
'fi' : Result := $040B; // Finnish
|
||||
'fr' : Result := $040C; // French
|
||||
'he' : Result := $040D; // Hebrew
|
||||
'it' : Result := $0410; // Italian
|
||||
'jp' : Result := $0411; // Japanese
|
||||
'pl' : Result := $0415; // Polish
|
||||
'pt' : Result := $0816; // Portuguese (Portugal)
|
||||
'ru' : Result := $0419; // Russian
|
||||
'tr' : Result := $041F; // Turkish
|
||||
'zh_cn', 'zh-cn': Result := $0804; // Chinese (China)
|
||||
'zh_tw', 'zh-tw': Result := $0404; // Chinese (Taiwan)
|
||||
// please complete if necessary. Language code and LCIDs can be found at
|
||||
// http://www.science.co.il/Language/Locale-codes.asp
|
||||
else raise Exception.CreateFmt('Language "%s" not supported. Please add to GetLCIDFromLangCode.',[ALang]);
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{ SetDefaultSettings changes the FormatSettings according to the selected
|
||||
language. Unfortunately there is not platform-independent way to do this
|
||||
at the moment. Here is the solution for Windows. }
|
||||
procedure UpdateFormatSettings(ALang: String);
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
LCID: Integer;
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}
|
||||
// Determine the LCID for the requested language
|
||||
LCID := GetLCIDFromLangCode(ALang);
|
||||
|
||||
// Now we update the format settings to the new language
|
||||
{$WARNINGS OFF}
|
||||
GetLocaleFormatSettings(LCID, DefaultFormatSettings);
|
||||
{$WARNINGS ON}
|
||||
|
||||
// We also store the code page that belongs to the new language. We'll need
|
||||
// that when converting FCL strings to UTF8.
|
||||
CodePage := 'cp'+GetLocaleStr(LCID, LOCALE_IDEFAULTANSICODEPAGE, '');
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
|
||||
{ TLocalizedForm }
|
||||
|
||||
{ FlipChildren does not work correctly with TRadioGroup and TCheckGroup. This
|
||||
work-around by-passes these classes for the FlipChildren action.
|
||||
A patch has been submitted to bugtracker fixing this issue permanently
|
||||
(http://mantis.freepascal.org/view.php?id=25408). This method is no longer
|
||||
needed once that patch has been included in Lazarus. }
|
||||
procedure TLocalizedForm.FlipChildren(AllLevels: Boolean);
|
||||
|
||||
procedure _DoFlipChildren(AControl: TWinControl);
|
||||
var
|
||||
C: TControl;
|
||||
i: Integer;
|
||||
begin
|
||||
if (not (AControl is TCustomRadioGroup)) and
|
||||
(not (AControl is TCustomCheckGroup))
|
||||
then begin
|
||||
for i:=0 to AControl.ControlCount-1 do begin
|
||||
C := AControl.Controls[i];
|
||||
if (C is TWinControl) and (TWinControl(C).ControlCount > 0) then
|
||||
_DoFlipChildren(TWinControl(C));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
if AllLevels then
|
||||
_DoFlipChildren(Self);
|
||||
inherited FlipChildren(false);
|
||||
end;
|
||||
|
||||
{ Each inherited form will have to put code in procedure
|
||||
UpdateTranslation(ALang: String) to translate strings not
|
||||
automatically handled by DefaultTranslator.
|
||||
Don't forget to call "inherited". }
|
||||
procedure TLocalizedForm.UpdateTranslation(ALang: String);
|
||||
var
|
||||
i: Integer;
|
||||
F: TLocalizedForm;
|
||||
begin
|
||||
if Application.MainForm = self then
|
||||
for i:=0 to Screen.FormCount-1 do
|
||||
if Screen.Forms[i] is TLocalizedForm then begin
|
||||
F := TLocalizedForm(Screen.Forms[i]);
|
||||
if F <> self then F.UpdateTranslation(ALang);
|
||||
end;
|
||||
|
||||
if Application.IsRTLLang(ALang) <> Application.IsRTLLang(CurrentLang) then
|
||||
FlipChildren(true);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
94
examples/translation/main.lfm
Normal file
94
examples/translation/main.lfm
Normal file
@ -0,0 +1,94 @@
|
||||
inherited MainForm: TMainForm
|
||||
Left = 371
|
||||
Height = 280
|
||||
Top = 150
|
||||
Width = 247
|
||||
Caption = 'Translation demo'
|
||||
ClientHeight = 280
|
||||
ClientWidth = 247
|
||||
OnCreate = FormCreate
|
||||
object Label1: TLabel[0]
|
||||
Left = 14
|
||||
Height = 13
|
||||
Top = 16
|
||||
Width = 76
|
||||
Caption = 'Select language'
|
||||
FocusControl = CbLanguage
|
||||
ParentColor = False
|
||||
end
|
||||
object CbLanguage: TComboBox[1]
|
||||
Left = 136
|
||||
Height = 21
|
||||
Top = 13
|
||||
Width = 100
|
||||
ItemHeight = 13
|
||||
Items.Strings = (
|
||||
'de - Deutsch'
|
||||
'en - English'
|
||||
'es - Español'
|
||||
'fr - Français'
|
||||
'he - Hebrew'
|
||||
'ru - Russian'
|
||||
)
|
||||
OnChange = CbLanguageChange
|
||||
Style = csDropDownList
|
||||
TabOrder = 0
|
||||
end
|
||||
object Button1: TButton[2]
|
||||
Left = 14
|
||||
Height = 25
|
||||
Top = 240
|
||||
Width = 222
|
||||
Caption = 'Open second form'
|
||||
OnClick = Button1Click
|
||||
TabOrder = 1
|
||||
end
|
||||
object RgDrinks: TRadioGroup[3]
|
||||
Left = 14
|
||||
Height = 97
|
||||
Top = 47
|
||||
Width = 218
|
||||
AutoFill = True
|
||||
Caption = 'Please select a drink'
|
||||
ChildSizing.LeftRightSpacing = 6
|
||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 1
|
||||
ClientHeight = 79
|
||||
ClientWidth = 214
|
||||
Items.Strings = (
|
||||
'beer'
|
||||
'wine'
|
||||
'water'
|
||||
)
|
||||
OnClick = RgDrinksClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object Button2: TButton[4]
|
||||
Left = 18
|
||||
Height = 25
|
||||
Top = 184
|
||||
Width = 158
|
||||
Caption = 'What did you select?'
|
||||
OnClick = Button2Click
|
||||
TabOrder = 3
|
||||
end
|
||||
object Bevel1: TBevel[5]
|
||||
Left = 9
|
||||
Height = 3
|
||||
Top = 224
|
||||
Width = 223
|
||||
Shape = bsTopLine
|
||||
end
|
||||
object LblCurrentSelection: TLabel[6]
|
||||
Left = 18
|
||||
Height = 13
|
||||
Top = 154
|
||||
Width = 86
|
||||
Caption = 'No drink selected.'
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
6
examples/translation/main.lrt
Normal file
6
examples/translation/main.lrt
Normal file
@ -0,0 +1,6 @@
|
||||
TMAINFORM.CAPTION=Translation demo
|
||||
TMAINFORM.LABEL1.CAPTION=Select language
|
||||
TMAINFORM.BUTTON1.CAPTION=Open second form
|
||||
TMAINFORM.RGDRINKS.CAPTION=Please select a drink
|
||||
TMAINFORM.BUTTON2.CAPTION=What did you select?
|
||||
TMAINFORM.LBLCURRENTSELECTION.CAPTION=No drink selected.
|
227
examples/translation/main.pas
Normal file
227
examples/translation/main.pas
Normal file
@ -0,0 +1,227 @@
|
||||
{ ------------------------------------------------------------------------------
|
||||
Steps to create a translated application
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
- In Project Options, activate i18n and specify a folder for translations
|
||||
Make sure that this folder can be found at run-time. If you use a relative
|
||||
filename it must be relative to the location of the exe.
|
||||
Select the option to automatically update the po file.
|
||||
|
||||
- Add DefaultTranslator to uses clause of main form
|
||||
|
||||
- If the project contains several forms that need translation:
|
||||
- Copy LocalizedForms.* (to be found in this project) to the folder of
|
||||
the new project
|
||||
- Inherit all forms to be translated from LocalizedForm
|
||||
(defined in LocalizedForms.pas)
|
||||
- For this purpose modify the class declaration of the forms to
|
||||
"class(TLocalizedForm)" instead of "class(TForm)"
|
||||
Open the lfm file ("view source (.lfm)") and change the first word to
|
||||
"inherited". See main.lfm and unit2.lfm for examples.
|
||||
- Create an empty unit to collect all resourcestrings of the project
|
||||
(this simplifies cross-form usage of strings).
|
||||
|
||||
- Declare each string that needs to be translated as a resourcestring. This
|
||||
is not absolutely necessary for component properties "Caption", "Text" or
|
||||
"Hint" which are transparently handled by DefaultTranslator.
|
||||
Explicitly declared resource strings are required for stringlist items,
|
||||
such as those of comboboxes, radiogroups etc.
|
||||
|
||||
- To create resource strings from existing code: create a resourcestring section
|
||||
at the end of the interface section of each unit, then <right click> on each
|
||||
string and select "Refactoring" | "Make Resource String..." This will create
|
||||
the resource strings and place the string into the declaration. Then copy all
|
||||
resource strings to the resource strings unit and delete the resourcestring
|
||||
sections. Or, enter the resource strings into the resource strings unit
|
||||
directly.
|
||||
|
||||
- Using poedit (or a similar translation program) translate the strings in the
|
||||
project's po file (to be found in the languages folder) to the languages that
|
||||
you support. When saving insert language code before ".po", i.e.
|
||||
"Project1.de.po" for German translation file of "Project1.po".)
|
||||
|
||||
- See "SelectLanguage()" for required procedures when changing language at
|
||||
run-time.
|
||||
}
|
||||
|
||||
unit Main;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
||||
StdCtrls, DefaultTranslator, LocalizedForms;
|
||||
|
||||
type
|
||||
|
||||
{ TMainForm }
|
||||
|
||||
// inherit from TLocalizedForm, .lfm file begins with "inherited" instead of "object"
|
||||
TMainForm = class(TLocalizedForm)
|
||||
Bevel1: TBevel;
|
||||
Button1: TButton;
|
||||
Button2: TButton;
|
||||
CbLanguage: TComboBox;
|
||||
Label1: TLabel;
|
||||
LblCurrentSelection: TLabel;
|
||||
RgDrinks: TRadioGroup;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure CbLanguageChange(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure RgDrinksClick(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
FSelectionTime: TTime;
|
||||
procedure SelectLanguage(ALang: String);
|
||||
protected
|
||||
procedure UpdateTranslation(ALang: String); override;
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
MainForm: TMainForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
Unit2, StringsUnit;
|
||||
|
||||
procedure TMainForm.Button1Click(Sender: TObject);
|
||||
begin
|
||||
Form2.Show;
|
||||
end;
|
||||
|
||||
{ This example demonstrates how a translated string can be composed of other
|
||||
words in phrases. }
|
||||
procedure TMainForm.Button2Click(Sender: TObject);
|
||||
begin
|
||||
if RgDrinks.ItemIndex = -1 then
|
||||
MessageDlg(LblCurrentSelection.Caption, mtInformation, [mbClose], 0)
|
||||
else
|
||||
MessageDlg(Format(rsYouSelectedAt, [
|
||||
RgDrinks.Items[RgDrinks.ItemIndex], TimeToStr(FSelectionTime)]),
|
||||
mtInformation, [mbClose], 0);
|
||||
{ The format mask rsYouSelectedAt ('You selected %0:s at %1:s.') contains
|
||||
two format placeholders %0:s and %1:s. The former one is replaced by the
|
||||
string with index 0 in the parameter list, the latter one by the string
|
||||
with index 1. When using multiple placeholders always use the index
|
||||
specifiers because the order of placeholders may change from language to
|
||||
language. }
|
||||
|
||||
{ Another comment: The strings used in "MessageDlg" can be translated by
|
||||
copying the files "lclstrconsts.*.po" to the languages folder.
|
||||
DefaultTranslater then includes these strings as well. Please note that
|
||||
we did not copy these files in this demo project to avoid duplication of
|
||||
Lazarus files. }
|
||||
end;
|
||||
|
||||
{ Event handler fired when a new language is selected in the language combobox.
|
||||
We extract the language code from the selected combobox item, and call the
|
||||
procedure "SelectLanguage". }
|
||||
procedure TMainForm.CbLanguageChange(Sender: TObject);
|
||||
var
|
||||
lang: String;
|
||||
p: Integer;
|
||||
begin
|
||||
if CbLanguage.ItemIndex > -1 then begin
|
||||
lang := CbLanguage.Items[CbLanguage.ItemIndex];
|
||||
p := pos(' ', lang);
|
||||
if p = 0 then p := pos('-', lang);
|
||||
if p = 0 then
|
||||
raise Exception.Create('Language items are not properly formatted');
|
||||
{ This string is essentially meant as a message to the programmer, it
|
||||
will - hopefully - never make its way to the user. Therefore, there is
|
||||
not need to use a resourcestring and activate if for translation. }
|
||||
lang := copy(lang, 1, p-1);
|
||||
SelectLanguage(lang);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
{ Lets start the program with English translation by default. You could also
|
||||
store language in a configuration file and apply that selection here. }
|
||||
SelectLanguage('en');
|
||||
end;
|
||||
|
||||
{ Another example how to combine translated strings, in this case for a
|
||||
label caption. }
|
||||
procedure TMainForm.RgDrinksClick(Sender: TObject);
|
||||
begin
|
||||
if RgDrinks.ItemIndex > -1 then
|
||||
LblCurrentSelection.Caption := Format(rsYouSelected, [RgDrinks.Items[RgDrinks.ItemIndex]]);
|
||||
FSelectionTime := time();
|
||||
end;
|
||||
|
||||
{ This is the main procedure that has to be called when changing language:
|
||||
- It replaces resourcestrings with the translated ones.
|
||||
- It activates the format settings corresponding to the new language
|
||||
- It tries to use the BiDi mode for the new language (not completely correct)
|
||||
- It calls "UpdateTranslation" for itself and for each form of the project -
|
||||
this way, the forms can do things that are not done automatically.
|
||||
- It updates the language selector combobox }
|
||||
procedure TMainForm.SelectLanguage(ALang: String);
|
||||
var
|
||||
i, p: Integer;
|
||||
lang: String;
|
||||
begin
|
||||
// Switch language - this is in DefaultTranslator
|
||||
SetDefaultLang(ALang);
|
||||
|
||||
// Switch default settings by calling the procedure provided in BasicLocalizedForm.pas.
|
||||
UpdateFormatSettings(ALang);
|
||||
|
||||
// Adjust BiDiMode to new language
|
||||
UpdateBiDiMode(ALang);
|
||||
|
||||
// Update items not automatically translated.
|
||||
UpdateTranslation(ALang);
|
||||
|
||||
// Select the new language in the language combobox.
|
||||
ALang := lowercase(ALang);
|
||||
for i:=0 to CbLanguage.Items.Count-1 do begin
|
||||
lang := CbLanguage.Items[i];
|
||||
p := pos(' ', lang);
|
||||
if p = 0 then p := pos('-', lang);
|
||||
if p = 0 then
|
||||
raise Exception.Create('Language items are not properly formatted.');
|
||||
lang := lowercase(copy(lang, 1, p-1));
|
||||
if lang = ALang then begin
|
||||
CbLanguage.ItemIndex := i;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Remember the new language. Forms may want to check in UpdateTranslation
|
||||
whether the new language has a different BiDiMode. }
|
||||
CurrentLang := ALang;
|
||||
end;
|
||||
|
||||
{ This method is inherited from LocalizedForm and manually inserts translated
|
||||
strings in cases where DefaultTranslator cannot do this. }
|
||||
procedure TMainForm.UpdateTranslation(ALang: String);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
{ The items of the radiogroup are not automatically handled by
|
||||
DefaultTranslator. Therefore, we have to assign the strings to the
|
||||
translated versions explicitly. }
|
||||
RgDrinks.Items[0] := rsBeer;
|
||||
RgDrinks.Items[1] := rsWine;
|
||||
RgDrinks.Items[2] := rsWater;
|
||||
|
||||
{ The label LblCurrentSelection is created by a Format statement. Since
|
||||
DefaultTranslator does not execute code we have to update the translation
|
||||
of the label here. It is sufficient to call RgDrinksClick here where the
|
||||
caption is re-composed by means of the Format statement. }
|
||||
RgDrinksClick(nil);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
32
examples/translation/stringsunit.pas
Normal file
32
examples/translation/stringsunit.pas
Normal file
@ -0,0 +1,32 @@
|
||||
{ This unit collects all resource strings of the project }
|
||||
unit StringsUnit;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
|
||||
resourcestring
|
||||
rsBeer = 'Beer';
|
||||
rsWine = 'Wine';
|
||||
rsWater = 'Water';
|
||||
rsYouSelected = 'You selected %s.';
|
||||
rsYouSelectedAt = 'You selected %0:s at %1:s.';
|
||||
rsTodayIs = 'Today is %s';
|
||||
rsOne = 'One';
|
||||
rsTwo = 'Two';
|
||||
rsThree = 'Three';
|
||||
rsFour = 'Four';
|
||||
rsFive = 'Five';
|
||||
rsSix = 'Six';
|
||||
rsSeven = 'Seven';
|
||||
rsEight = 'Eight';
|
||||
rsNine = 'Nine';
|
||||
rsSumOfSelectedNumbers = 'Sum of selected numbers: %s';
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
142
examples/translation/translation_demo.lpi
Normal file
142
examples/translation/translation_demo.lpi
Normal file
@ -0,0 +1,142 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="translation_demo"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N Value="True"/>
|
||||
<OutDir Value="languages"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="2">
|
||||
<Item1 Name="Debug" Default="True"/>
|
||||
<Item2 Name="Release">
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<StripSymbols Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</Item2>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="5">
|
||||
<Unit0>
|
||||
<Filename Value="translation_demo.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="translation_demo"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="main.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="MainForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Main"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="localizedforms.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="LocalizedForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="LocalizedForms"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="unit2.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form2"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit2"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="stringsunit.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="StringsUnit"/>
|
||||
</Unit4>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="translation_demo"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="units\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<UseMsgFile Value="True"/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
23
examples/translation/translation_demo.lpr
Normal file
23
examples/translation/translation_demo.lpr
Normal file
@ -0,0 +1,23 @@
|
||||
program translation_demo;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, Main, LocalizedForms, Unit2, StringsUnit
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.CreateForm(TLocalizedForm, LocalizedForm);
|
||||
Application.CreateForm(TForm2, Form2);
|
||||
Application.Run;
|
||||
end.
|
||||
|
BIN
examples/translation/translation_demo.res
Normal file
BIN
examples/translation/translation_demo.res
Normal file
Binary file not shown.
99
examples/translation/unit2.lfm
Normal file
99
examples/translation/unit2.lfm
Normal file
@ -0,0 +1,99 @@
|
||||
inherited Form2: TForm2
|
||||
Left = 635
|
||||
Height = 280
|
||||
Top = 148
|
||||
Width = 288
|
||||
Caption = 'Second Form'
|
||||
ClientHeight = 280
|
||||
ClientWidth = 288
|
||||
OnCreate = FormCreate
|
||||
object LblTodayIs: TLabel[0]
|
||||
Left = 16
|
||||
Height = 15
|
||||
Top = 16
|
||||
Width = 57
|
||||
Caption = 'LblTodayIs'
|
||||
ParentColor = False
|
||||
end
|
||||
object LblMoney: TLabel[1]
|
||||
Left = 16
|
||||
Height = 15
|
||||
Top = 40
|
||||
Width = 53
|
||||
Caption = 'LblMoney'
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
end
|
||||
object GroupBox1: TGroupBox[2]
|
||||
Left = 16
|
||||
Height = 160
|
||||
Top = 72
|
||||
Width = 256
|
||||
Caption = 'Please select'
|
||||
ClientHeight = 142
|
||||
ClientWidth = 252
|
||||
TabOrder = 0
|
||||
object RadioGroup: TRadioGroup
|
||||
Left = 7
|
||||
Height = 90
|
||||
Top = 9
|
||||
Width = 111
|
||||
AutoFill = True
|
||||
Caption = 'Single item'
|
||||
ChildSizing.LeftRightSpacing = 6
|
||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 1
|
||||
ClientHeight = 72
|
||||
ClientWidth = 107
|
||||
ItemIndex = 0
|
||||
Items.Strings = (
|
||||
'one'
|
||||
'two'
|
||||
'three'
|
||||
)
|
||||
OnSelectionChanged = RadioGroupSelectionChanged
|
||||
TabOrder = 0
|
||||
end
|
||||
object CheckGroup: TCheckGroup
|
||||
Left = 134
|
||||
Height = 90
|
||||
Top = 9
|
||||
Width = 104
|
||||
AutoFill = True
|
||||
Caption = 'Several items'
|
||||
ChildSizing.LeftRightSpacing = 6
|
||||
ChildSizing.TopBottomSpacing = 6
|
||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
||||
ChildSizing.ShrinkHorizontal = crsScaleChilds
|
||||
ChildSizing.ShrinkVertical = crsScaleChilds
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 1
|
||||
ClientHeight = 72
|
||||
ClientWidth = 100
|
||||
Items.Strings = (
|
||||
'one'
|
||||
'two'
|
||||
'three'
|
||||
)
|
||||
OnItemClick = CheckGroupItemClick
|
||||
TabOrder = 1
|
||||
Data = {
|
||||
03000000020202
|
||||
}
|
||||
end
|
||||
object LblSum: TLabel
|
||||
Left = 7
|
||||
Height = 15
|
||||
Top = 112
|
||||
Width = 231
|
||||
AutoSize = False
|
||||
Caption = 'LblSum'
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
||||
end
|
7
examples/translation/unit2.lrt
Normal file
7
examples/translation/unit2.lrt
Normal file
@ -0,0 +1,7 @@
|
||||
TFORM2.CAPTION=Second Form
|
||||
TFORM2.LBLTODAYIS.CAPTION=LblTodayIs
|
||||
TFORM2.LBLMONEY.CAPTION=LblMoney
|
||||
TFORM2.GROUPBOX1.CAPTION=Please select
|
||||
TFORM2.RADIOGROUP.CAPTION=Single item
|
||||
TFORM2.CHECKGROUP.CAPTION=Several items
|
||||
TFORM2.LBLSUM.CAPTION=LblSum
|
130
examples/translation/unit2.pas
Normal file
130
examples/translation/unit2.pas
Normal file
@ -0,0 +1,130 @@
|
||||
unit Unit2;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||
ExtCtrls, LocalizedForms;
|
||||
|
||||
type
|
||||
|
||||
{ TForm2 }
|
||||
|
||||
TForm2 = class(TLocalizedForm)
|
||||
CheckGroup: TCheckGroup;
|
||||
GroupBox1: TGroupBox;
|
||||
LblSum: TLabel;
|
||||
LblMoney: TLabel;
|
||||
LblTodayIs: TLabel;
|
||||
RadioGroup: TRadioGroup;
|
||||
procedure CheckGroupItemClick(Sender: TObject; Index: integer);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure RadioGroupSelectionChanged(Sender: TObject);
|
||||
private
|
||||
procedure CalculateSum;
|
||||
protected
|
||||
procedure UpdateTranslation(ALang: String); override;
|
||||
public
|
||||
end;
|
||||
|
||||
var
|
||||
Form2: TForm2;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
LConvEncoding, // for ConvertEncoding - see "UpdateTranslation"
|
||||
StringsUnit;
|
||||
|
||||
procedure TForm2.FormCreate(Sender: TObject);
|
||||
begin
|
||||
UpdateTranslation(CurrentLang);
|
||||
end;
|
||||
|
||||
{ This procedure shows
|
||||
- how to combine translated resource strings by means of the format statement
|
||||
- how to use arrays of resource strings: use pointers to the resource strings! }
|
||||
procedure TForm2.CalculateSum;
|
||||
const
|
||||
numbers: array[1..9] of PString = (@rsOne, @rsTwo, @rsThree, @rsFour, @rsFive,
|
||||
@rsSix, @rsSeven, @rsEight, @rsNine);
|
||||
var
|
||||
sum: Integer;
|
||||
begin
|
||||
sum := RadioGroup.ItemIndex + 1;
|
||||
if CheckGroup.Checked[0] then sum := sum + 1;
|
||||
if CheckGroup.Checked[1] then sum := sum + 2;
|
||||
if CheckGroup.Checked[2] then sum := sum + 3;
|
||||
LblSum.Caption := Format(rsSumOfSelectedNumbers, [numbers[sum]^]);
|
||||
end;
|
||||
|
||||
procedure TForm2.CheckGroupItemClick(Sender: TObject; Index: integer);
|
||||
begin
|
||||
CalculateSum;
|
||||
end;
|
||||
|
||||
procedure TForm2.RadioGroupSelectionChanged(Sender: TObject);
|
||||
begin
|
||||
CalculateSum;
|
||||
end;
|
||||
|
||||
procedure TForm2.UpdateTranslation(ALang: String);
|
||||
var
|
||||
s: String;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
{ DefaultTranslator cannot execute code, i.e. strings combined by means of
|
||||
the Format statement are not translated automatically. Such a string is
|
||||
created for the caption of LblSum in "CalculateSum" - we have to call this
|
||||
method here to get that label translated. }
|
||||
CalculateSum;
|
||||
|
||||
{ There is a complication for the labels LblTodayIs which displays the current
|
||||
date, and with LblMoney with displays some amount of money with the currency
|
||||
sign.
|
||||
Formatting for these data is extracted from the DefaultFormatSettings.
|
||||
The resulting strings are encoded in ansi and do not display locale-specific
|
||||
characters. To get this right they have to be converted to UTF8.
|
||||
Usually, it is sufficient to call SysToUTF8 for this purpose. Our example,
|
||||
however, allows for Hebrew characters which are usually not contained in the
|
||||
typical code pages. Therefore, we use'll a more general procedure based on
|
||||
ConvertEncoding which allows to specify the source code page which had been
|
||||
determined when UpdateFormatSettings had been called in the LocalizedForms
|
||||
unit. }
|
||||
s := ConvertEncoding(
|
||||
FormatDateTime(DefaultFormatSettings.LongDateFormat, date), // string to convert
|
||||
CodePage, // source encoding as defined by "CodePage"
|
||||
EncodingUTF8 // destination encoding - UTF8
|
||||
);
|
||||
LblTodayIs.Caption := Format(rsTodayIs, [s]);
|
||||
{ Note: "ConvertEncoding" requires the unit LConvEncoding in the uses clause. }
|
||||
|
||||
{ Now the same with LblMoney... }
|
||||
LblMoney.Caption := ConvertEncoding(
|
||||
Format('%.*n %s', [
|
||||
DefaultFormatSettings.CurrencyDecimals,
|
||||
10e6,
|
||||
DefaultFormatSettings.CurrencyString
|
||||
]),
|
||||
CodePage, EncodingUTF8
|
||||
);
|
||||
|
||||
{ The items of TRadiogroup are not translated automatically. }
|
||||
with RadioGroup do begin
|
||||
Items[0] := rsOne;
|
||||
Items[1] := rsTwo;
|
||||
Items[2] := rsThree;
|
||||
end;
|
||||
|
||||
{ We should translate CheckGroup here also. But we don't do this here
|
||||
to demonstrate the effect when the items of the CheckGroup are not
|
||||
translated explicitly as we did with the RadioGroup. }
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user