translation
Same string with different translation
You can use gettext’s context for that. Django has added support for that in 1.3 release (in code) and 1.4 (for templates), see https://docs.djangoproject.com/en/dev/topics/i18n/translation/#contextual-markers Update: For example following code: from django.utils.translation import pgettext, ugettext month = pgettext(“month name”, “May”) month = pgettext(“fifth month”, “May”) month = ugettext(“May”) Translates to: #: foo/views.py:4 msgctxt “month name” msgid … Read more
put new line in string to translate
You can use \n but you will have to provide some styling. So in your template use this: <div class=”my-translated-paragraph”> {{‘STRING_TO_TRANSLATE’ | translate}} </div> Your en.json: { “STRING_TO_TRANSLATE”: “text on first line.\nText on second line” } Your (s)CSS file: .my-translated-paragraph{ white-space: pre-wrap; } More info an the magic behind white-space: https://stackoverflow.com/a/42354356/3757110 See also a github … Read more
How to get the current language in Django?
Functions of particular interest are django.utils.translation.get_language() which returns the language used in the current thread. See documentation.
Non-English texts in Stripe possible?
For further reference: While you can’t use human messages on stripe errors to be displayed directly on localized pages, you can take advantage of response.error.code to provide your own translations. var errorMessages = { incorrect_number: “The card number is incorrect.”, invalid_number: “The card number is not a valid credit card number.”, invalid_expiry_month: “The card’s expiration … Read more
How to convert gettext .mo file into .po file [closed]
msgunfmt [path_to_file.mo] > [path_to_file.po]
django – how to make translation work?
Just add the paths of the locale files generated to the settings.py file like the following LOCALE_PATHS = ( “/xxx/xxx/Projects/xxx/sites/avb/locale/”,)
How do you handle translation of text with markup?
Solution 2 is what you want. Send them the whole sentence, with the HTML markup embedded. Reasons: The predominant translation tool, Trados, can preserve the markup from inadvertent corruption by a translator. Trados can also auto-translate text that it has seen before, even if the content of the tags have changed (but the number of … Read more
Access translation file (i18n) from inside rails model
Call: I18n.t instead of simple t. t is a helper method only available in the views, delegating the whole logic to I18n module. UPDATE: As mentioned in the comments, view helper is not only delegating to the I18n module, it makes sure that you can use a default scopes as well.
Unable to find a locale path to store translations for file __init__.py
Turns out you need to create a locale folder first using mkdir locale. If you are running the command from within an app folder, you need a locale folder within that app folder.