3 ms·
His advice of thinking of phrases as functions is spot on. However I think he's missing the easiest way of formulating solutions that would be usable by many tr
by Nitramp 16y ago
His advice of thinking of phrases as functions is spot on. However I think he's missing the easiest way of formulating solutions that would be usable by many translators/linguists: pattern matching.
Imagine your phrase/function is called:
"Found %n1 matching files in %n2 directories"
You could pattern match for one particular language like this:
%n1 == 0, %n2 == 0
%n1 == 1, %n2 == 1
%n1 > 1, %n2 == 1
... and so on ...
With the matching being any (simple?) boolean function of the operator, applied in order. At the point where this becomes too cumbersome, you could fall back to proper code. I bet that this would be much easier to use for translators, with an optional fallback to a programmer if it gets too complex to spell out all combinations.
- unwind 16y agoGNU gettext has something like this, see http://www.gnu.org/software/hello/manual/gettext/Plural-forms.html http://www.gnu.org/software/hello/manual/gettext/Plural-form... for instance. Not sure if the article referenced this, I got the feeling it didn't since it started talking about replacing gettext pretty early on.
- ost 16y agoGNU gettext dispatches on a single number, i.e. it can handle cases like "Scanned %u directories", but not "Scanned %u files in %u directories".
- jwr 16y agoYou're simplifying things. Please remember that in many languages the form of the numeral depends not only on the number, but also on what it is you're counting. And you don't always know that if you're deep inside a library. In general, there is no easy way out — and you have to allow for exceptions. Please see my other comment, about an architectural takeaway.
- Nitramp 16y agoLike I said, I understand and appreciate that arbitrary functions are required for a complete solution. I just think that this kind of matching would be a solution for a subset of problems (languages) large enough to make it useful.
- Natsu 16y ago> Please remember that in many languages the form of the numeral depends not only on the number, but also on what it is you're counting. And you don't always know that if you're deep inside a library. Japanese, for example: http://en.wikipedia.org/wiki/Japanese_counter_word http://en.wikipedia.org/wiki/Japanese_counter_word Take the counter 本, for a commonly-used example. That's used for: "Long, thin objects: rivers, roads, train tracks, ties, pencils, bottles, guitars; also, metaphorically, telephone calls, train or bus routes, movies (see also: tsūwa), points or bounds in sports events. Although 本 also means "book", the counter for books is satsu (冊)."
- Vivtek 16y agoBut doesn't the counter always follow the numeral in a non-declined manner in Japanese? That is, a pattern like "%n-satsu book" would work, right? I thought of Japanese, too, but I think maybe this is a pattern that is the inverse of the problem discussed.
- Natsu 16y agoSo long as you know what you're counting, you're fine, yes. But the real problem is that we have a different problem in each language. Every single language has its own way to do things and that's where we run into trouble, because you need generic ways of doing things and there really isn't one for all languages. You essentially need one function to create text for each language, even though some of them can share helper functions, like that one for numerals.
- Vivtek 16y agoOh - I'm not doubting the original point! I'm a professional translator myself. I know how weird it can get (most of my languages are Germanic and Romance and provide no great headaches, but Hungarian is hard to translate well).