internationalization

How do I tell why Django is ignoring the Accept-Language header?

好久不见. 提交于 2019-12-10 19:26:33
问题 I have a Django app (on Google App Engine) that I wish to internationalize. settings.py: USE_I18N = True LANGUAGE_CODE = 'en' # Restrict supported languages (and JS media generation) LANGUAGES = ( ('en', 'English'), ('fr', 'French'), ) MIDDLEWARE_CLASSES = ( 'ragendja.middleware.ErrorMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', # i18n 'django.middleware.locale.LocaleMiddleware', ... I have generated .po and .mo files for my app in locale/fr/LC_MESSAGES (though not at

Django - Switch language setting for template rendering [duplicate]

江枫思渺然 提交于 2019-12-10 19:10:46
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Django switching, for a block of code, switch the language so translations are done in one language Is there an easy way to get Django to switch language for a single template rendering operation? In my case the user may trigger an event that will require to message a person that is not speaking the same language. For instance - user is English speaker but invokes an action that messages a Spanish speaking

translate a HTML select element in Grails

时光怂恿深爱的人放手 提交于 2019-12-10 19:04:29
问题 thought this would be easier.... imagine a <g:select /> like this: <g:select name="type.id" from="${Type.list()}" value="${domainInstance?.type?.id}" /> with two domain classes like this (please forgive me if these artificial classes are not error free) class Domain { Type type } class Type { String name } I would now like to translate the entries of the select element. The following code first looked good: <g:select name="type.id" from="${Type.list()}" valueMessagePrefix="type.name" value="$

Choosing localization for unsupported languages

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 18:50:41
问题 I have localizations for "en" and "ru" languages, and if user select any other language (fr,de...) I need to display Russian localization variant. I tried changing "Localization native development region" in info.plist to "ru" / "Russian", but it always displays English, when using unsupported language. There is related question from which I'm assuming this task is impossible. I would be grateful for any advice and insights on these issues. 回答1: I think with my solution posted here Localizing

Making Django queries with localized dates

萝らか妹 提交于 2019-12-10 18:49:44
问题 In my form I have a DateField called booking_date that is rendered with the AdminDateWidget. The contents of the booking_date field needs to be internationalized. The problem appears when I want to use the value of the field in something like this: booking = Booking.objects.get(booking_number='BN34D', booking_date='2010-11-21') But if my date format is '%d.%m.%Y' : booking = Booking.objects.get(booking_number='BN34D', booking_date='21.11.2010') I get a 'ValidationError: Enter a valid date in

Reimplementing ToUpper()

时光总嘲笑我的痴心妄想 提交于 2019-12-10 18:25:15
问题 How would you write ToUpper() if it didn't exist? Bonus points for i18n and L10n Curiosity sparked by this: http://thedailywtf.com/Articles/The-Long-Way-toUpper.aspx 回答1: I download the Unicode tables I import the tables into a database I write a method upper(). Here is a sample implementation ;) public static String upper(String s) { if (s == null) { return null; } final int N = s.length(); // Mind the optimization! PreparedStatement stmtName = null; PreparedStatement stmtSmall = null;

Rails Internationalization: i18n look up with nested locales directories

隐身守侯 提交于 2019-12-10 17:49:20
问题 I am trying to organize my localization files with a nested file structure so that it is easier to look up. I have followed Organization of Locale Files in rails app How do you structure i18n yaml files in Rails? but I am getting a translation missing: en.view.fruits.apple . I think that Rails is trying to only look up the translation in locales/en.yml file but not the sub-directories although, I have included them. config/application.rb: config.i18n.load_path += Dir["#{Rails.root.to_s}

WooCommerce - Translate a word on the Checkout page

ぃ、小莉子 提交于 2019-12-10 17:42:30
问题 I'm trying to translate a word on the WooCommerce checkout page. My website is in the Dutch language, but they translated it poorly, so I want to use a different word. What needs to be translated It concerns the following line: "Totaal €469,38 (Inclusief €79,38 Belasting )" In English this says: "Total €469,38 (Includes €79,38 tax )" It's the line that sums up the total amount of the order. And I want to translate the word 'Belasting' to 'BTW'. What I've tried Checked out settings in

CommandError: Can't find xgettext. with django i18n

痴心易碎 提交于 2019-12-10 17:41:26
问题 I have building a simple application with django in which I am using I18N . But when I tried to run following command, D:\work\i18n\testapp>django-admin.py makemessages -l en I am getting following error , D:\work\i18n\testapp>django-admin.py makemessages -l en CommandError: Can't find xgettext. Make sure you have GNU gettext tools 0.15 or newer installed. After this I have installed python-gettext , but I am still getting CommandError: Can't find xgettext... error. Here is my setting.py """

facebook opengraph crawler doesn't send me fb_locale

橙三吉。 提交于 2019-12-10 17:40:56
问题 I have an opengraph object that supports multiple locales (in this example, en_US by default and fr_FR). This is an example of the generated html page that is used by the facebook opengraph but when I call it myself. Default: <meta property="og:locale" content="en_US"/> <meta property="og:locale:alternate" content="en_US" /> <meta property="og:locale:alternate" content="fr_FR" /> <meta property="og:title" content="chair" /> ?fb_locale=en_US <meta property="og:locale" content="en_US"/> <meta