internationalization

Preventing HTML character entities in locale files from getting munged by Rails3 xss protection

北城余情 提交于 2019-12-31 11:43:03
问题 We're building an app, our first using Rails 3, and we're having to build I18n in from the outset. Being perfectionists, we want real typography to be used in our views: dashes, curled quotes, ellipses et al. This means in our locales/xx.yml files we have two choices: Use real UTF-8 characters inline. Should work, but hard to type, and scares me due to the amount of software which still does naughty things to unicode. Use HTML character entities (’ — etc). Easier to type, and probably more

Preventing HTML character entities in locale files from getting munged by Rails3 xss protection

雨燕双飞 提交于 2019-12-31 11:41:18
问题 We're building an app, our first using Rails 3, and we're having to build I18n in from the outset. Being perfectionists, we want real typography to be used in our views: dashes, curled quotes, ellipses et al. This means in our locales/xx.yml files we have two choices: Use real UTF-8 characters inline. Should work, but hard to type, and scares me due to the amount of software which still does naughty things to unicode. Use HTML character entities (’ — etc). Easier to type, and probably more

Correct java.util.ResourceBundle Organization

让人想犯罪 __ 提交于 2019-12-31 07:10:34
问题 I have an internationalized project with many modules. Each module has its own set of bundles: - database-module + com_naugler_project_database.properties + com_naugler_project_database_fr.properties - mapping-module + com_naugler_project_mapping.properties + com_naugler_project_mapping_fr.properties However, many of the internationalized terms are redundant (such as 'OK' or 'Cancel') and I would like have these terms in one place for easier maintenance and development. I found this helpful

VelocityTools error - “java.util.MissingResourceException: Can't find bundle for base name WEB-INF.conf.resources.ss_messages, locale en_US”

落爺英雄遲暮 提交于 2019-12-31 05:18:08
问题 I'm trying to integrate VelocityTools.ResourceTool to localize velocity template but whatever I use as the 'bundles' parameter I keep getting the following error: java.util.MissingResourceException: Can't find bundle for base name WEB-INF.conf.resources.ss_messages, locale en_US I'm using VelocityTools v1.4. Here are my configurations: Tool config /WEB-INF/conf/misc/velocity/toolbox.xml <tool> <key>test</key> <scope>request</scope> <class>org.apache.velocity.tools.generic.ResourceTool</class>

how to determine year, month, day ordering based on locale?

心已入冬 提交于 2019-12-31 05:15:42
问题 I would like to display three custom dropdowns for the user to select year, month, and day of their identification card. How can I determine which order to show the year, month, and day, using only JavaScript (not moment )? Example output for en-US : ['month', 'day', 'year'] Example output for en-CA : ['year', 'month', 'day'] 回答1: function datePartOrder(locale) { const parts = new Intl.DateTimeFormat(locale).formatToParts(); const filteredParts = parts.filter(part => ['year', 'month', 'day']

How to set locale in a custom Struts 2 ActionMapper

元气小坏坏 提交于 2019-12-31 05:08:05
问题 I have implemented a custom ActionMapper which obtains the locale from the URI (the URI itself, not the request parameters). From within ActionMapper.getMapping(), how do I set the locale for the current action? Here are some ideas I've considered: ActionContext.getCurrent().setLocale(). Unfortunately, it seems that a fresh new ActionContext is created when the action is invoked, and the locale is reset to the default. Set the parameter request_locale, which will be processed by the i18n

Rails 3 translations within models in production

末鹿安然 提交于 2019-12-31 05:05:12
问题 I'm trying to translate an app into Japanese and everything was going smoothly until I put it into production. As cache_classes is now true any translation within a model reverts to the default locale. I know I'm probably supposed to target the translations directly in the yml file but I'm not sure how I would do that for the following simplified code: class TimeseriesForecast < ActiveRecord::Base @@field_names = { :location_name => I18n.t('forecast_timeseries.location_name'), :local_date

Django modeltranslation queries fallback

别说谁变了你拦得住时间么 提交于 2019-12-31 01:43:38
问题 I'm using django modeltranslation for a multi-language site. Language fallback works good when reading attributes directly. For example, if current language is German and I print object.title, if the German title is not defined I'll see the english title. I would expect fallback to work also on queries, but that's not true. In fact, if i do something like results = MyModel.objects.filter(title = 'hello') this will get no results if the German title is not set, while I would like it to return

Default language via settings not respected during testing

谁都会走 提交于 2019-12-30 18:51:04
问题 Using Django 1.3, Python 2.6 Having a particularly weird problem to track down related to internationalization, and RequestFactory vs. TestClient for testing views. If I run: ./manage.py test All tests run (including the problematic ones) and pass successfully. If I run: ./manage.py test <appname> The app's tests will fail, throwing a template rendering exception for templates that use the language code because the language django thinks the request is asking for is not a language we've

Default language via settings not respected during testing

不羁的心 提交于 2019-12-30 18:50:09
问题 Using Django 1.3, Python 2.6 Having a particularly weird problem to track down related to internationalization, and RequestFactory vs. TestClient for testing views. If I run: ./manage.py test All tests run (including the problematic ones) and pass successfully. If I run: ./manage.py test <appname> The app's tests will fail, throwing a template rendering exception for templates that use the language code because the language django thinks the request is asking for is not a language we've