digitalmars.D - Do multilanguage application
- bioinfornatics (6/6) Aug 12 2011 Dear,
- Jacob Carlborg (10/16) Aug 14 2011 It's fairly simple. You just need a file containing keys and values.
- Johannes Pfau (12/32) Aug 14 2011 I think the std.string functions tr, translate, maketrans are meant to
- Sean Kelly (4/45) Aug 14 2011 For serious i18n work I'd use ICU. I believe Mango even has a wrapper fo...
Dear, I would like to know how do a multilanguage application. It seem it is possible by using flag -J but they are no document for this feature. link givent in this page http://www.digitalmars.com/d/2.0/dmd-linux.html seem to be wrong if you can do a little example, will be nice thanks kind regards
Aug 12 2011
On 2011-08-12 23:02, bioinfornatics wrote:Dear, I would like to know how do a multilanguage application. It seem it is possible by using flag -J but they are no document for this feature. link givent in this page http://www.digitalmars.com/d/2.0/dmd-linux.html seem to be wrong if you can do a little example, will be nice thanks kind regardsIt's fairly simple. You just need a file containing keys and values. This file can be read either at compile time or runtime. Read the file into an associative array and when you need a piece of text translated just pass the key to a function which retries the corresponding value from the associative array. You could take a look at how internalization is don in Ruby on Rails, this can be applied to D as well: http://guides.rubyonrails.org/i18n.html -- /Jacob Carlborg
Aug 14 2011
Jacob Carlborg wrote:On 2011-08-12 23:02, bioinfornatics wrote:I think the std.string functions tr, translate, maketrans are meant to do that. But there's a lot more to proper i18n and even for translation a simple key/value table isn't perfect. gettext for example also handles plural forms and context information. (A translation might be different depending on it's context.) Implementing all this stuff can get quite difficult, just have a look at the plural formulas for different languages: http://translate.sourceforge.net/wiki/l10n/pluralformsDear, I would like to know how do a multilanguage application. It seem it is possible by using flag -J but they are no document for this feature. link givent in this page http://www.digitalmars.com/d/2.0/dmd-linux.html seem to be wrong if you can do a little example, will be nice thanks kind regardsIt's fairly simple. You just need a file containing keys and values. This file can be read either at compile time or runtime. Read the file into an associative array and when you need a piece of text translated just pass the key to a function which retries the corresponding value from the associative array.You could take a look at how internalization is don in Ruby on Rails, this can be applied to D as well: http://guides.rubyonrails.org/i18n.html-- Johannes Pfau
Aug 14 2011
For serious i18n work I'd use ICU. I believe Mango even has a wrapper for so= me of it.=20 Sent from my iPhone On Aug 14, 2011, at 8:50 AM, Johannes Pfau <spam example.com> wrote:Jacob Carlborg wrote:On 2011-08-12 23:02, bioinfornatics wrote:Dear, I would like to know how do a multilanguage application. It seem it is possible by using flag -J but they are no document for this feature. link givent in this page http://www.digitalmars.com/d/2.0/dmd-linux.html seem to be wrong =20 if you can do a little example, will be nice =20 thanks =20 kind regards=20 It's fairly simple. You just need a file containing keys and values.=20 This file can be read either at compile time or runtime. Read the file=20=into an associative array and when you need a piece of text translated=20=just pass the key to a function which retries the corresponding value=20 from the associative array.=20 I think the std.string functions tr, translate, maketrans are meant to do that. But there's a lot more to proper i18n and even for translation a simple key/value table isn't perfect. gettext for example also handles plural forms and context information. (A translation might be different depending on it's context.) =20 Implementing all this stuff can get quite difficult, just have a look at the plural formulas for different languages: http://translate.sourceforge.net/wiki/l10n/pluralforms =20=20 You could take a look at how internalization is don in Ruby on Rails,=20 this can be applied to D as well: http://guides.rubyonrails.org/i18n.html =20=20 =20 --=20 Johannes Pfau =20
Aug 14 2011