Hello all,
I just saw a library for dealing with displaying to multiple languages at: http://search.cpan.org/~petdance/Locale-Maketext-1.10/lib/Locale/Maketext.pod Does anyone know of anything like this for Squeak? I'm sure something like this could be made much more powerful and elegant in ST. If there isn't, then this would be a good project for someone. This kind of thing will get more and more important on the web. (and yes, I will do it myself if no one else does by the time I get around to it :). Thanks, Jason |
> Does anyone know of anything like this for Squeak? I'm sure something > like this could be made much more powerful and elegant in ST. > > If there isn't, then this would be a good project for someone. This > kind of thing will get more and more important on the web. (and yes, I > will do it myself if no one else does by the time I get around to it > :). Gettext is available for GNU Smalltalk, it should not be hard to port it. Paolo |
You didn't look at the link. :) The point is that gettext is only
useful in the most trivial of cases. From a functional programming point of view, a mapping from one language to another can't always be expressed as a simple string translation. In many cases it has to be a function, and that's what this library allows you to do. On 10/12/07, Paolo Bonzini <[hidden email]> wrote: > > > Does anyone know of anything like this for Squeak? I'm sure something > > like this could be made much more powerful and elegant in ST. > > > > If there isn't, then this would be a good project for someone. This > > kind of thing will get more and more important on the web. (and yes, I > > will do it myself if no one else does by the time I get around to it > > :). > > Gettext is available for GNU Smalltalk, it should not be hard to port it. > > Paolo > > |
Ok, here is a better link:
http://search.cpan.org/~petdance/Locale-Maketext-1.10/lib/Locale/Maketext/TPJ13.pod On 10/12/07, Jason Johnson <[hidden email]> wrote: > You didn't look at the link. :) The point is that gettext is only > useful in the most trivial of cases. From a functional programming > point of view, a mapping from one language to another can't always be > expressed as a simple string translation. In many cases it has to be > a function, and that's what this library allows you to do. > > On 10/12/07, Paolo Bonzini <[hidden email]> wrote: > > > > > Does anyone know of anything like this for Squeak? I'm sure something > > > like this could be made much more powerful and elegant in ST. > > > > > > If there isn't, then this would be a good project for someone. This > > > kind of thing will get more and more important on the web. (and yes, I > > > will do it myself if no one else does by the time I get around to it > > > :). > > > > Gettext is available for GNU Smalltalk, it should not be hard to port it. > > > > Paolo > > > > > |
In reply to this post by Jason Johnson-5
Jason Johnson wrote:
> You didn't look at the link. :) I did, but only the first two or three pages which seemed the same as Gettext. :) Paolo |
In reply to this post by Jason Johnson-5
So maketext allows the translator to not only translate phrases, but
put in Perl code to generate them. Fine. But most translators are not hackers and vice versa. And going with an established system has its merits even though it may be not quite perfect (although gettext actually does handle multiple plural forms). There is a whole lot of infrastructure built around gettext already. At least that's why we went with gettext for Etoys now (https://translations.launchpad.net/etoys/). - Bert - On Oct 12, 2007, at 20:22 , Jason Johnson wrote: > Ok, here is a better link: > > http://search.cpan.org/~petdance/Locale-Maketext-1.10/lib/Locale/ > Maketext/TPJ13.pod > > On 10/12/07, Jason Johnson <[hidden email]> wrote: >> You didn't look at the link. :) The point is that gettext is only >> useful in the most trivial of cases. From a functional programming >> point of view, a mapping from one language to another can't always be >> expressed as a simple string translation. In many cases it has to be >> a function, and that's what this library allows you to do. >> >> On 10/12/07, Paolo Bonzini <[hidden email]> wrote: >>> >>>> Does anyone know of anything like this for Squeak? I'm sure >>>> something >>>> like this could be made much more powerful and elegant in ST. >>>> >>>> If there isn't, then this would be a good project for someone. >>>> This >>>> kind of thing will get more and more important on the web. (and >>>> yes, I >>>> will do it myself if no one else does by the time I get around >>>> to it >>>> :). >>> >>> Gettext is available for GNU Smalltalk, it should not be hard to >>> port it. >>> >>> Paolo >>> |
On 10/14/07, Bert Freudenberg <[hidden email]> wrote:
> So maketext allows the translator to not only translate phrases, but > put in Perl code to generate them. Fine. Put in code to generate them, yes. Perl just happened to be the first place I've seen this implemented. > But most translators are not hackers and vice versa. For sure. > And going with > an established system has its merits even though it may be not quite > perfect (although gettext actually does handle multiple plural > forms). There is a whole lot of infrastructure built around gettext > already. At least that's why we went with gettext for Etoys now > (https://translations.launchpad.net/etoys/). > > - Bert - Doesn't gettext handle the plural forms by making you put in a translation for each case, in every language? Did you read the "horror story" part from the second link I sent? If that story is bogus then gettext is probably fine. |
> Doesn't gettext handle the plural forms by making you put in a
> translation for each case, in every language? Did you read the > "horror story" part from the second link I sent? If that story is > bogus then gettext is probably fine. It is not fully bogus. The fact that Slavic and Baltic languages use different cases for some endings of the numeral is true, see http://en.wikipedia.org/wiki/Lithuanian_grammar#Noun_modification_by_numeral for an example. However, other part of the horror story are a bit exaggerated. For example, in Italian "0 file trovati" (compare with "1 file trovato" and "2 file trovati") is a perfectly fine sentence, though less elegant than "Nessun file trovato" ("No file found"). But then, "0 files found" sounds a little weird in English too. Also I don't think that the exponential explosion of translation strings is unavoidable if you want to have multiple numerals in a single sentences. For example, in English you can choose to have up to seven strings like these (%d meaning any number >1): 0 files and 0 directories were found 1 file was found (and 0 directories) 1 directory was found (and 0 files) 1 file and 1 directory were found %d files and 1 directory were found 1 file and %d directories were found %d files and %d directories were found ... or you can use the following strings: Found %s and %s 1 file 1 directory %d files %d directories This set does not grow exponentially and, while in general %s should be avoided, in this case it should be relatively easy to translate without problems (e.g. in Italian it would not work to translate the first literally, but you could translate it as "I found %s and %s"). Regarding actual experiences with gettext, G++ translation has problems because it computes parts of a sentence using printf and %s, which is a no-no. I suggested having multiple strings for the same phrase (e.g. "template") for the different prepositions/cases ("of a template", "within a template", "to a template",...) but the patch was rejected. In this cases, maketext probably would not need some of the contortions that I had to apply, but those contortions are in maketext itself and it would not place less burden on the translator. Paolo |
In reply to this post by Jason Johnson-5
On Oct 15, 2007, at 6:39 , Jason Johnson wrote:
> On 10/14/07, Bert Freudenberg <[hidden email]> wrote: >> So maketext allows the translator to not only translate phrases, but >> put in Perl code to generate them. Fine. > > Put in code to generate them, yes. Perl just happened to be the first > place I've seen this implemented. > >> But most translators are not hackers and vice versa. > > For sure. > >> And going with >> an established system has its merits even though it may be not quite >> perfect (although gettext actually does handle multiple plural >> forms). There is a whole lot of infrastructure built around gettext >> already. At least that's why we went with gettext for Etoys now >> (https://translations.launchpad.net/etoys/). >> >> - Bert - > > Doesn't gettext handle the plural forms by making you put in a > translation for each case, in every language? If a language has only one form of plural you only need to put in one. If there are more plural forms, of course you need to put them all in if you want a perfect translation: http://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html > Did you read the > "horror story" part from the second link I sent? If that story is > bogus then gettext is probably fine. It's not entirely bogus. But gettext has been extended to handle these cases, see above. I guess the one case that it cannot handle is if you have two numerals in the same phrase. Which can certainly be worked around with by splitting the phrase in two. - Bert - |
Ah ok. Thanks for the info (and you too Paolo). I guess gettext is
definitaly workable. I guess this kind of thing would be something someone could take a proper language like Smalltalk and research it, but in the mean time gettext works. On 10/15/07, Bert Freudenberg <[hidden email]> wrote: > On Oct 15, 2007, at 6:39 , Jason Johnson wrote: > > > On 10/14/07, Bert Freudenberg <[hidden email]> wrote: > >> So maketext allows the translator to not only translate phrases, but > >> put in Perl code to generate them. Fine. > > > > Put in code to generate them, yes. Perl just happened to be the first > > place I've seen this implemented. > > > >> But most translators are not hackers and vice versa. > > > > For sure. > > > >> And going with > >> an established system has its merits even though it may be not quite > >> perfect (although gettext actually does handle multiple plural > >> forms). There is a whole lot of infrastructure built around gettext > >> already. At least that's why we went with gettext for Etoys now > >> (https://translations.launchpad.net/etoys/). > >> > >> - Bert - > > > > Doesn't gettext handle the plural forms by making you put in a > > translation for each case, in every language? > > If a language has only one form of plural you only need to put in > one. If there are more plural forms, of course you need to put them > all in if you want a perfect translation: > > http://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html > > > Did you read the > > "horror story" part from the second link I sent? If that story is > > bogus then gettext is probably fine. > > It's not entirely bogus. But gettext has been extended to handle > these cases, see above. I guess the one case that it cannot handle is > if you have two numerals in the same phrase. Which can certainly be > worked around with by splitting the phrase in two. > > - Bert - > > > > |
In reply to this post by Bert Freudenberg
On Oct 15, 2007, at 1:53 AM, Bert Freudenberg wrote:
I recently did some work to localize Dabble to Spanish. I started with the simplest possible thing and gradually added features to accomodate the situations I ran into. The result is not all that different from gettext or maketext (though I'm not intimately familiar with those libraries). Briefly, it works like this: Each language has a class, and each translation is a method on that class. Most of those methods just answer a string literal, but some answer a Phrase, which has methods for filing in parameters to the phrase or customizing the way it gets printed on a stream or rendered as HTML. On top of that, there's a bit of infrastructure for creating translations easily. There's a TranslationBrowser built on OmniBrowser, and some code for compiling templates in to Smalltalk that returns a Phrase. As you can see, it also allows different translations for plurals, with each language specifying which plural forms it has to support. We don't support more than one plural per phrase, and so far it hasn't been an issue. That could be just an oddity of Dabble's UI design, though. The classic example would be something like this. Let say the phrase is '{bold:Alert!} We found {count} files.' We might render it in Seaside something like this: renderFilesFoundOn: html (self language filesFound: 3) render: #bold with: [:text | html strong: text]; renderOn: html That would produce '<strong>Alert!</strong> We found 3 files.' Or it could be printed to a stream: printFilesFoundOn: aStream (self language filesFound: 3) print: #bold with: [:text | aStream nextPut: $*; nextPutAll: text; nextPut: $*]; printOn: aStream] Producing '*Alert!* We found 3 files' To also report the number of directories, you'd have to combine two plural translations, embedding one inside the other: (self language foundDirectoriesWithFiles: 3) set: #directories to: (self language directoriesFound: 2); printOn: aStream All in all, it works reasonably well, and makes localization less painful, though not completely painless. It's pretty easy to implement, really. Colin |
Free forum by Nabble | Edit this page |