[Lazarus] Resource strings and newline
Péter Gábor
ptrg at freemail.hu
Tue Jun 17 19:48:19 CEST 2014
Sometimes translators (and maybe developers) need to reorder the
appearance of parameters using the parameter ordering feature of
Format() function. See:
http://www.freepascal.org/docs-html/rtl/sysutils/format.html
Which is very difficult without exactly knowing the meaning of all %s
symbols.
Here is an example source string:
msgid="There is already a file%s%s%sin package %s"
An ugly translation for Hungarian language:
msgstr="Már van egy %s%s%s fájl a(z) %s csomagban"
It would look more friendly and natural for users this way:
msgstr="A(z) %3:s csomagban%0:smár van egy %1:s fájl"
Note: in this source string %0:s and %2:s is for new line and may/can be
ommited if no need for (one of) them in the translation.
The first translation will look like this:
Már van egy
unit99.pas
fájl a(z) valami99 csomagban
The second translation will look more user friendly, like this:
A(z) valami99 csomagban
már van egy unit99.pas fájl
(A little explanation: "A(z)" is meaning two possible definite article
depending on the first letter of the next word: "az" before vowels and
"a" before consonants. I don't know about that gettext supports this
kind of language features.)
Today the string mustcontain the same number of %s symbols (including
the ones referencing for LineEndings) to avoid getting error messages
from POChecker.
Rewriting of (resource)strings (and the related source codes) using
hardcoded LineEndings (#13#10 or #10 or #13) will place \n into .po
files at the right positions and on re-reading them system specific
LineEndings will be placed into the memory.
So POChecker will not shout if a %s (which is for LineEnding) is missing
and translation can/will be easier, producing much more user friendly
Lazarus... and application created with it.
Finally: I think that if the above changes will be done the result will
go beyond the translations, it will result in a better and managable
source code for Lazarus.
2014-06-17 15:52 keltezéssel, Juha Manninen írta:
>
>
> On Tuesday, June 17, 2014, Péter Gábor <ptrg at freemail.hu
> <mailto:ptrg at freemail.hu>> wrote:
>
>
> Can someone change the title of the bug-report #26343 to something
> that is more descriptive and refers to what we are talking about there?
>
> eg.: lazaruside.*.po contains semi converted and/or confusing strings:
> "%s%s%s"
>
>
> I will explain what has happened so far.
>
> First I noticed the usage of double quote character in resource strings
> is inconsistent. Some were hard coded inside a string and some were
> passed as Format parameter %s.
> Together with other parameters they often formed long, 5 or 6,
> parameters in row. Their meaning was not obvious and had to be dug from
> source code.
>
> I changed some and removed few duplicates, but then I decided to switch
> all quotation marks to hard coded. They were plenty but still it is only
> a small fraction of all resource strings in Lazarus project.
> Often the resource strings are generated with a tool. It used to add
> parameters for quotes but does't any more. Thus the change was logical,
> the usage of quotes will be consistent.
>
> Gábor's bug report is about parameters used for newlines. They are not
> "semi converted". I did not touch them, they have been there always.
> It seems to be possible to use #13#10 inside the string instead of
> using parameters. Why is it not done for Lazarus IDE strings, I don't
> know. Maybe other Lazarus developers could comment on this.
>
> There is a massive amount of those parametrized newlines and the tools
> are generating more of them. It is not realistic to change them,
> although I personally would like to see parameters used only for truly
> varying data.
>
> Regards
> Juha
>
>
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
--
Péter Gábor
ptrg at freemail.hu
More information about the Lazarus
mailing list