How do I get localized date pattern string?

For SimpleDateFormat, You call toLocalizedPattern() EDIT: For Java 8 users: The Java 8 Date Time API is similar to Joda-time. To gain a localized pattern we can use class DateTimeFormatter DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM); Note that when you call toString() on LocalDate, you will get date in format ISO-8601 Note that Date Time API in Java 8 is … Read more

How to translate model in Ruby class/module namespace?

I have checked ‘model_name.human’ source code and found ‘i18n_key’ method. I have tried this: irb(main):006:0> Products::Car.model_name.i18n_key => :”products/car” Then I changed my yml file to this: activerecord: models: products/car: “Автомобиль” attributes: products/car: owner: “Владелец” and it works! EDIT: For further reference: the i18n_key is set in the initializer of ActiveModel::Name https://github.com/rails/rails/blob/375a4143cf5caeb6159b338be824903edfd62836/activemodel/lib/active_model/naming.rb#L147 and it is simply … Read more

How to create multilingual translated routes in Laravel

First step: Go to app/lang directory and create here translations for your routes for each language. You need to create 3 routes.php files – each in separate language directory (pl/en/fr) because you want to use 3 languages For Polish: <?php // app/lang/pl/routes.php return array( ‘contact’ => ‘kontakt’, ‘about’ => ‘o-nas’ ); For English: <?php // … Read more

localization of assets files

This isn’t supported directly but here is what I have done… Separate your files into groups by country code (like what you would do for normal resource files) and then create a localized string in each of your localized string.xml files called something like “prefix” (where prefix would be “en” for English for example). Then … Read more

How to format a Float Value with the device currency format?

For sake of completeness suppose you want to display a price in phone’s current locale (correct decimal mark and thousand separator) but with a currency of your choice. NumberFormat format = NumberFormat.getCurrencyInstance(Locale.getDefault()); format.setCurrency(Currency.getInstance(“CZK”)); String result = format.format(1234567.89); result would then hold these values: CZK1,234,567.89 with US locale 1 234 567,89 Kč with Czech locale If … Read more