internationalization

Trouble on using the i18n gem with partial template files

流过昼夜 提交于 2019-12-04 02:05:14
I am using Ruby on Rails 3.1 and I would like to know how to correctly handle internationalization related to partial template files. That is, ... ... in my app/views/users/flag.html.erb file I have: <%= t('.test_key1') %> <%= render :partial => "/users/flag_form" %> ... in my app/views/users/_flag_form.html.erb file I have: <%= t('.test_key2') %> If in my config/locales/views/users/en.yml file ( note : I am organizing files as stated in the official RoR guide ) I use en: users: flag: test_key1: Test 1 text test_key2: Test 2 text the Test 1 text is displayed in the "main" template ( app/views

In struts2 internationalization in Arabic how to automatically change cursor in textboxes to rtl?

我与影子孤独终老i 提交于 2019-12-04 01:43:04
问题 I have implemented internationalization in my Struts2 application and it is working fine, but how do I change the cursor position automatically in all the textboxes in all the jsp to RTL when I select Arabic as the language? If you could give me a simple example it would be very helpful. 回答1: How about adding dir attribute to the <html> tag in JSP-s, using Struts2 <s:if> tag to check current locale language: <html <s:if test="locale.language == 'ar'">dir="rtl"</s:if> > ... </html> 回答2: Try

Where to place i18n key strings in Java

白昼怎懂夜的黑 提交于 2019-12-04 01:17:50
When doing internationalization in Java, you assign a string key to each message. What's the best practice, on where to place those string keys. Goal is to allow easy refactoring (eg. key name changes), clean and readable code, separation of concerns but still no duplication of keys/messages even if called from different parts of the code. //bad way, strings directly in code messages.getString("hello_key"); - // better way, use String constants public static final String HELLO_KEY = "hello_key"; ... messages.getString(HELLO_KEY); - // other (better?) way, put all keys in one huge central class

poedit workaround for dynamic gettext

微笑、不失礼 提交于 2019-12-04 01:17:19
问题 I have started using gettext for translating text and messages i send to user. I am using poedit as an editor, but i am struggling with dynamic messages. For example i have things like the login where i have a variable that tells the type of error. $this->translate('page-error-' . $error); When i auto update from poedit this gets read like "page-error-". What i do is have a file where i place dummy calls to the translate method with all the possible keys to have them added in my poedit when

\d only matchs 0-9 digits?

你离开我真会死。 提交于 2019-12-04 00:34:32
问题 As far as I know, \d should matchs non-english digits, e.g. ۱۲۳۴۵۶۷۸۹۰ but it doesn't work properly in JavaScript. See this jsFiddle: http://jsfiddle.net/xZpam/ Is this a normal behavior? 回答1: JavaScript does not support Unicode regex matching (and it is far from the only language where such is true). http://www.regular-expressions.info/unicode.html 回答2: It seems that JavaScript does not support this (along with other weaknesses of the language in RegExp). However there's a library called

internationalization of dates on the web

微笑、不失礼 提交于 2019-12-04 00:29:27
Does anyone have any good "architecture" for the internationalization of dates? like in English its Monday, Chinese: 星期一, Dutch: maandag, Japanese: 月曜日 So my first idea is to create some sort of class that stores the strings of Monday to Sunday in 59 different languages. Apparently this isn't scalable at all, imagine now I need to display "12:34 A.M, Monday, 1st Jan 2000" I will then need another translation for A.M, P.M, the months (both long and short forms), the ordinals, etc, etc. It's too much work, what's the solution? Chris Walton The approach you suggest is not scalable. The Microsoft

How to handle single quotes in internationalization constants?

隐身守侯 提交于 2019-12-03 23:52:22
We define all our internationalized constant strings in a single properties file LocalizableResource_xx.properties (one per language) located in google.gwt.i18n.client . This way it is possible to access the constants in Java code via the constants interface Window.alert(myConstants.helloWorld()); as well as to use them inside the UiBinder .ui.xml <ui:attribute key="some.key" name="text" description="useful info" /> This approach doesn't work well if the string contains a single quote ( ' ). This is because the GWT compiler throws a java.text.ParseException: Unterminated single quote: when it

How to achieve multilingual support in ASP.NET

旧巷老猫 提交于 2019-12-03 23:18:14
I want to internationalize my asp.net application. How to do this? What steps exactly do I have to follow? Simply make a basepage class that will inherited from Page class, put this method in basepage class and inherit basepage class in your every aspx.cs page to acheive globalization. protected override void InitializeCulture() { Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); base.InitializeCulture(); } set in this method whatever culuture you want, like ar-sa for arabic.... 1.) If you use database, then you

Are named entities in HTML still necessary in the age of Unicode aware browsers?

爱⌒轻易说出口 提交于 2019-12-03 23:03:32
I did a lot of PHP programming in the last years and one thing that keeps annoying me is the weak support for Unicode and multibyte strings (to be sure, natively there is none). For example, "htmlentities" seems to be a much used function in the PHP world and I found it to be absolutely annoying when you've put an effort into keeping every string localizable, only store UTF-8 in your database, only deliver UTF-8 webpages etc. Suddenly, somewhere between your database and the browser there's this hopelessly naive function pretending every byte is a character and messes everything up. I would

How can the cache for the views with translations be invalidated?

我的未来我决定 提交于 2019-12-03 21:52:55
Imagine you have two views with code like the following: controller_a/a.html.erb <%= content_tag(:div) do %> <%= I18n.t "some.key" %> <% end %> controller_b/b.html.erb <%= content_tag(:div) do %> <%= I18n.t "some.key" %> <% end %> <%= content_tag(:div) do %> <%= I18n.t "some.other_key" %> <% end %> So, a.html.erb is on controller_a#a, while b.html.erb is on controller_b#b. Both actions are cached by caches_action . How can I make sure that when I change the some.key translation key, both views are invalidated? How could I build a generic mechanism? Say, in your ApplicationController create the