i18n with gettext but without the locale hassle?
This method should work even with non-standard locales: $locale=”someWeirdLocale”; putenv(‘LC_MESSAGES=’ . $locale); bindtextdomain(‘domain’, ‘./locale’); textdomain(‘domain’); Enjoy!
This method should work even with non-standard locales: $locale=”someWeirdLocale”; putenv(‘LC_MESSAGES=’ . $locale); bindtextdomain(‘domain’, ‘./locale’); textdomain(‘domain’); Enjoy!
GetText should be able to do, search for “extract” at http://dxgettext.po.dk/documentation/how-to If all you need is to translate GUI and maybe resourcestring in sources, and the inline string constants in Pascal sources are not needed for translation, then you can try Delphi built-in method. However forums say that ITE is buggy. But at least that … Read more
In addition to gettext already mentioned, PHP 5.3 has native Internationalization support If that’s not an option, consider using Zend Framework’s Zend_Translate, Zend_Locale and related components for that. Zend_Translate supports a number of adapters, including but not limited to simple arrays, gettext, XmlTm and others.
The Class#getResourceAsStream() can take a path which is relative to the location of the Class which you’re using there as starting point. So, for example, if the class is located in the com.example package and you request the path foo/filename.properties, then it will actually load the com/example/foo/filename.properties file. But if you use /foo/filename.properties, then it … Read more
You can do something like this. As in your answer, you would either want to implement this as a singleton, or use a DI framework to inject a single instance wherever you need it: public class ObservableResourceFactory { private ObjectProperty<ResourceBundle> resources = new SimpleObjectProperty<>(); public ObjectProperty<ResourceBundle> resourcesProperty() { return resources ; } public final ResourceBundle … Read more
You’ll need to create a function that has all the letters you know are RTL and check when loading. To display RTL you need the CSS attributes, direction, text-align, and unicode-bidi. Demo: Script function checkRtl( character ) { var RTL = [‘ا’,’ب’,’پ’,’ت’,’س’,’ج’,’چ’,’ح’,’خ’,’د’,’ذ’,’ر’,’ز’,’ژ’,’س’,’ش’,’ص’,’ض’,’ط’,’ظ’,’ع’,’غ’,’ف’,’ق’,’ک’,’گ’,’ل’,’م’,’ن’,’و’,’ه’,’ی’]; return RTL.indexOf( character ) > -1; }; var divs = document.getElementsByTagName( ‘div’ ); … Read more
i18n has built-in support for using the database as a translation backend. Create a table using this code in a migration: create_table :translations do |t| t.string :locale t.string :key t.text :value t.text :interpolations t.boolean :is_proc, :default => false end Then add an initializer in config/initializers/i18n.rb with contents: I18n.backend = I18n::Backend::ActiveRecord.new And last… put translations in … Read more
Here is a regular expression that can be used to match all English alphanumeric characters, Japanese katakana, hiragana, multibytes of alphanumerics (hankaku and zenkaku), and dashes: /[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]+|[a-zA-Z0-9]+|[a-zA-Z0-9]+|[々〆〤ヶ]+/u You can edit it to fit your needs, but notice the “u” flag at the end.
Part of the confusion here is that PHP has two concepts called “locale” that are pretty much totally separate. The first is the older one, which basically just uses the C locale features. That’s what’s behind setlocale and the locale support in some of PHP’s functions (like money_format for example). This is what other answers … Read more