Sign in Join
Wiki copytemporary

Getting translation strings right/es: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11Esta página contiene algunas notas básicas acerca de como traducir cadenas de forma correcta desde el principio, desde el punto de vista de los escritores originales (e.g. muy a menudo programadores).
22
33"Para hacer lo correcto" en este contexto, significa que las cadenas de traducción se han preparado apropiadamente para una traducción lo más aproximada posible, y que la versión original se ha adaptado a los requerimientos básicos para su uso.
44
55Aunque se trata de que sea lo más neutral posible al lenguaje, hay de hecho una ligera tendencia al inglés en particular. Sentiros libres para extender o descartalas a lo que no sea aplicable a vuestra situación (¿y puede que también las añadais a esta página?).
66
77### General
88
99Para evitar problemas, simplemente asegúrate de que **las cadenas originales están correctas** en primer lugar - hay algunas razones para hacer esto:
1010
1111- Las cadenas originalmente se utilizan habitualmente como traducciones por defecto, creando una mala impresión al usuario final que suele utilizar las cadenas por defecto.
1212
1313- Incluso peor, esto hace el trabajo del traductor innecesariamente duro: tendrá más problemas al trasladar la información original a otro lenguaje.Simplemente recuerda el principio "Basura de entrada, Basura de salida" que se aplica aquí perfectamente.
1414
1515#### Asegúrate de que las cadenas en tu lenguaje original están impecables, claras y consistentes
1616
1717Given the above, please find some tips when writing messages/strings for user consumption.
1818
1919Trata de asegurarte de que tu **ortografía sea correcta** - utiliza un diccionario si no estás seguro.
2020
2121Utiliza frases comprensibles y bien conocidas para la situación que se quiere describir, de una manera **consistente**. Si no tienes la seguridad de que sea la interpretación correcta , prueba a poner otros programas en la misma situación y examina sus respuestas. La literatura y ficheros de ayuda son además frecuentemente un buen recurso para acertar con frases o términos especiales, o incidencias de estilo.
2222
2323Prueba a ser consistente también a la hora de escoger las frases. Por ejemplo las preguntas:
2424
25-`Delete the file?`\
26-`Erase the file?`\
27-`Remove the file?`\
28-`Wipe the file?`\
29-`Zap the file?`
25+```text
26+Delete the file?
27+Erase the file?
28+Remove the file?
29+Wipe the file?
30+Zap the file?
31+```
3032
3133tienen todas un significado similar, pero cuando se utilizan de manera intercambiable, los lectores pueden empezar a probar e inventar un (no existente) significado cada distinta terminología.
3234
3335Los traductores son especiamente muy propensos a cometer este error, dado que a menudo desconocen el contexto exacto de un mensaje en particular (e.g. información sobre el mensaje original) y pueden interpretar variaciones de palabras como indicación de diferencias importantes y estará tentado de utilizar traducciones poco comunes y por tanto malas traducciones.
3436
3537Un montón de software de traducción (e.g Virtaal) te puede ayudar de dos maneras:
3638
3739- Tiene una memoria de traducción que te permite recordar todas las cadenas (strings) ya traducidas y ayudarte a traducir términos consistentemente.
3840
3941- Te muestra como se encuentran traducidas las cadenas en otros softwares de código abierto, ofreciéndote las formas más frecuentemente utilizadas.
4042
4143Especially for error messages to the user: try to **describe the problem** itself in appropriate words. This is never the state of the program which led to the error message. This is only useful for the person debugging the program, but not for the user. Users will either simply shrug their shoulders and ignore it in the best case, or choose another program in the worst case because without a proper problem description the user will not be able to fix the problem and continue his work - all that only because the program was not able to give a proper problem description.
4244
4345Give (easily) **understandable descriptions**. Do not try to impress your audience with foreign or very technical words only for telling that the current work has not yet been saved if not really necessary.
4446
4547Especially try to avoid multiple negations within a single sentence in your wordings, they are nearly always harder to read than their non-negated counterparts. An example could be
4648
47-`This component can not be dropped on non-TControls.`
49+```text
50+This component can not be dropped on non-TControls.
51+```
4852
4953which, in its non-negated form
5054
51-`This component can only be dropped on TControls.`
55+```text
56+This component can only be dropped on TControls.
57+```
5258
5359is certainly easier to read and understand.
5460
5561### Technical issues
5662
5763In this section a short overview of technical issues, basically an overview of existing possibilites are given. These include the resourcestring construct, GNU gettext() and the format() function.
5864
5965#### Resourcestrings, and GNU gettext
6066
6167Free Pascal has some built-in language constructs for providing a way of handling constant strings. There is a special section of a unit called "resourcestring" which was specifically introduced for this reason. See the appropriate section of the FPC manual (prog.pdf, pg. 89ff or [here](http://www.freepascal.org/docs-html/prog/progch9.html#x184-1870009)) for the details.
6268
6369GNU gettext is a special set of utilities to provide translations for your programs, see the FPC manual once more (prog.pdf, pg. 91ff or [here](http://www.freepascal.org/docs-html/prog/progse41.html#x210-2130009.4)).
6470
6571> **Note:** GNU gettext has a conceptual flaw which does not allow mapping of a single original string to multiple translated strings, be aware of that.
6672
6773#### ResourceStrings in the IDE
6874
6975- Lazarus has a tool to easily create resourcestrings from string constants. See [[IDE Window: Make ResourceString|Make ResourceString]]
7076
7177- For each resourcestring section FPC creates a .rst file, but there are no editor for these files. Lazarus can automatically create .po files of the .rst files. There are a lot of tools to edit .po files (e.g. kbabel).
7278
7379To enable creating the .po files for a package do the following:
7480
75-` * Create a sub directory 'languages' (or 'locale', or whatever)`\
76-` * Open the package. Then Options -> IDE Integration -> Directory of .po files set to `*`languages`*
81+```text
82+ * Create a sub directory 'languages' (or 'locale', or whatever)
83+ * Open the package. Then Options -> IDE Integration -> Directory of .po files set to languages
84+```
7785
7886The next time you compile the package, the IDE will create the .po files.
7987
8088> **Note:** The .rst files must belong to package units. Otherwise the IDE ignores foreign .rst files.
8189
8290The same works for projects. The directory is set in Project -\> Project Options -\> IDE Integration -\> Directory of .po files.
8391
8492- To create a German translation: copy the unit1.po file to unit1.de.po. Then use a text editor or a .po Editor to translate all strings.
8593
8694- The IDE will automatically load .po files for installed packages, if they exists. For example see lazarus/components/projecttemplates/languages/.
8795
8896- ToDo: Implement and document updating the translated .po files when new resourcestrings are added.
8997
9098- ToDo: Implement and document collecting all .po files of statically linked packages.
9199
92100#### ResourceStrings in your Application
93101
94102You can load the .po files at initialization to translate the resourcestrings. Add this to your .lpr file:
95103
96104``` pascal
97105...
98106uses
99107 ...
100108 Translations, LazUTF8;
101109
102110procedure TranslateLCL;
103111var
104112 PODirectory, Lang, FallbackLang: String;
105113begin
106114 PODirectory:='/path/to/lazarus/lcl/languages/';
107115 Lang:='';
108116 FallbackLang:='';
109117 LazGetLanguageIDs(Lang,FallbackLang); // in unit LazUTF8
110118 Translations.TranslateUnitResourceStrings('LCLStrConsts',
111119 PODirectory+'lclstrconsts.%s.po',Lang,FallbackLang);
112120 // ... add here a TranslateUnitResourceStrings call for every po file ...
113121end;
114122
115123begin
116124 TranslateLCL;
117125 Application.Initialize;
118126 Application.CreateForm(TForm1, Form1);
119127 Application.Run;
120128end.
121129```
122130
123131> **Note:** for Mac OS X: The supported language IDs should be added into the application bundle property list to CFBundleLocalizations key, see lazarus.app/Contents/Info.plist for example.
124132
125133#### The format() function
126134
127135To not only allow completely static strings in translations, you can use the [[doc:rtl/sysutils/format.html|format()]] method of the sysutils unit. It is able to replace placeholders within a given text by their actual value given as secondary parameter in a set.
128136
129137Por ejemplo:
130138
131-`format('Mañana `**`%0:s`**`  `**`%1:s`**` el sol. ', [`**`'Domingo`**`', `**`'brillará`**`']);`
139+```text
140+format('Mañana %0:s %1:s el sol. ', ['Domingo', 'brillará']);
141+```
132142
133143retornara
134144
135-`Mañana `**`Domingo`**` `**`brillará`**` el sol`
145+```text
146+Mañana Domingo brillará el sol
147+```
136148
137149In this case the %0:s is a placeholder para el primer argumento (index 0) in the set of actual values (Sunshine), and likewise %1:s. For an exact definition of the allowed placeholders and their syntax see the FPC reference manual.
138150
139151Some guidelines for the usage of the format() function
140152
141153- Try to use indexed placeholders in the original strings, even if they are optional. When used, they allow the translator to move the arguments easily within the sentence allowing him more natural expressions (and actually sometimes moving sentence parts is required to create proper sentences in that language).
142154
143155- Never compose a sentence out of more than one string. Always use the format() method from the sysutils unit to construct the correct string using placeholders during runtime. Translators will usually not be able to reconstruct the whole sentence, therefore not able to give a good translation; only consider that there are often hundreds of such strings within a single translation database...
144156
145157- Do not format using whitespaces. Simply move your label to the appropriate position in the first place. There may be problems with font changes, and seemingly superfluous spaces will be in danger of being trimmed by the translator.
146158
147159> **Note:** ~~Since format() does not interpret escaped control characters (e.g. like C's "\n", "\t", etc) and GNU gettext for any reason being the translation system of choice (and the tools based on it not being able to interpret non-escaped control characters), it is required to programmatically insert linebreaks.~~In the current lazarus version, "\n" and "\t" in translated strings are replaced by newline and tab.
148160
149161#### Convirtiendo la traducción al código de caracteres correcto
150162
151163Por ejemplo: convirtiendo un fichero de ISO-8859-1 a UTF-8:
152164
153-` iconv --from-code=ISO-8859-1 --to-code=UTF-8 oldfile.po > nuevofichero.po`
165+```text
166+ iconv --from-code=ISO-8859-1 --to-code=UTF-8 oldfile.po > nuevofichero.po
167+```
154168
155169No olvidarse de cambiar la línea:
156170
157-` "Content-Type: text/plain; charset=ISO-8859-1\n"`
171+``` pascal
172+ "Content-Type: text/plain; charset=ISO-8859-1\n"
173+```
158174
159175por
160176
161-` "Content-Type: text/plain; charset=UTF8\n"`
177+``` pascal
178+ "Content-Type: text/plain; charset=UTF8\n"
179+```
162180
163181### English related
164182
165183This section contains notes which particularly apply when using English as the base language for translations.
166184
167185- Make sure to reserve enough space where the text is output: English is a language in which texts are almost always shorter (in characters) than their respective translations, so plan ahead by reserving enough space. Experience shows that very short strings of a few characters length often almost double in size; this difference decreases as the strings get longer.
168186
169187- Avoid abbreviations in English; in addition to the fact that this shortens the already short strings even more, there are severe problems with e.g. languages that use ideographic characters where these abbreviations simply do not exist at all.
170188
171189- Since this is often an issue: In English punctuation marks (full stop, comma, ...) are part of the previous words, or form some sort of words themselves if there is no previous word (in case of an enumeration). Especially after a semicolon there should always be a trailing space.
172190
173-`There was an error ! Please check file settings , compiler settings,... to fix this issue.`
191+```text
192+There was an error ! Please check file settings , compiler settings,... to fix this issue.
193+```
174194
175195has horrible punctuation and therefore simply looks bad and is harder to read than usual. Consider that common line break algorithms break the line on whitespaces, possibly resulting in a single stop at the beginning of a line...
176196
177-`There was an error! Please check file settings, compiler settings, ... to fix this issue.`
197+```text
198+There was an error! Please check file settings, compiler settings, ... to fix this issue.
199+```
178200
179201would probably be okay only considering punctuation.
180202
181203### See also
182204
183205- [[Translations / i18n / localizations for programs]]
184206- [[Lazarus Documentation|Translating/Internationalization/Localization]]
185207- [[Step-by-step instructions for creating multi-language applications]]
186208
187209---
188210*From the Free Pascal wiki, page "Getting translation strings right/es", as it stood on 2020-02-16 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history