Example: en-us. See How Django discovers language preference. Hebrew, Arabic. English, French, German, etc. If you enable the django. You can also retrieve information about any of the available languages using provided template tags and filters. If you do this in your view:. Django provides an integrated solution for these problems: It passes the translations into JavaScript, so you can call gettext , etc.
The main solution to these problems is the following JavaScriptCatalog view, which generates a JavaScript code library with functions that mimic the gettext interface, plus an array of translation strings. A view that produces a JavaScript code library with functions that mimic the gettext interface, plus an array of translation strings.
Translation domain containing strings to add in the view output. Defaults to 'djangojs'. A list of application names among installed applications. Those apps should contain a locale directory. The precedence of translations is such that the packages appearing later in the packages argument have higher precedence than the ones appearing at the beginning. This is important in the case of clashing translations for the same literal.
If you use more than one JavaScriptCatalog view on a site and some of them define the same strings, the strings in the catalog that was loaded last take precedence. When the catalog is loaded, your JavaScript code can use the following methods:. The gettext function behaves similarly to the standard gettext interface within your Python code:. The ngettext function provides an interface to pluralize words and phrases:. The interpolate function supports dynamically populating a format string.
The interpolation syntax is borrowed from Python, so the interpolate function supports both positional and named interpolation:. Positional interpolation: obj contains a JavaScript Array object whose elements values are then sequentially interpolated in their corresponding fmt placeholders in the same order they appear. Named interpolation: This mode is selected by passing the optional boolean named parameter as true. This emulates the gettext function but does nothing, returning whatever is passed to it:.
The pgettext function behaves like the Python variant pgettext , providing a contextually translated word:. The npgettext function also behaves like the Python variant npgettext , providing a pluralized contextually translated word:.
The pluralidx function works in a similar way to the pluralize template filter, determining if a given count should use a plural form of a word or not:. In the simplest case, if no custom pluralization is needed, this returns false for the integer 1 and true for all other numbers. However, pluralization is not this simple in all languages. If the language does not support pluralization, an empty value is provided. Additionally, if there are complex rules around pluralization, the catalog view will render a conditional expression.
This will evaluate to either a true should pluralize or false should not pluralize value. In order to use another client-side library to handle translations, you may want to take advantage of the JSONCatalog view. See the documentation for JavaScriptCatalog to learn about possible values and use of the domain and packages attributes. Server-side caching will reduce CPU load. To trigger cache invalidation when your translations change, provide a version-dependent key prefix, as shown in the example below, or map the view at a version-dependent URL:.
Client-side caching will save bandwidth and make your site load faster. Otherwise, you can apply conditional decorators. In the following example, the cache is invalidated whenever you restart your application server:.
You can even pre-generate the JavaScript catalog as part of your deployment procedure and serve it as a static file. This radical technique is implemented in django-statici18n. Using either one of these features requires that an active language be set for each request; in other words, you need to have django.
If localized URLs get reversed in templates they always use the current language. To link to a URL in another language use the language template tag. It enables the given language in the enclosed template section:. The language tag expects the language code as the only argument. Once the string literals of an application have been tagged for later translation, the translation themselves need to be written or obtained.
The first step is to create a message file for a new language. A message file is a plain-text file, representing a single language, that contains all available translation strings and how they should be represented in the given language.
Message files have a. Django comes with a tool, django-admin makemessages , that automates the creation and upkeep of these files. The makemessages command and compilemessages discussed later use commands from the GNU gettext toolset: xgettext , msgfmt , msgmerge and msguniq.
The minimum version of the gettext utilities supported is 0. When you run makemessages from the root directory of your project, the extracted strings will be automatically distributed to the proper message files. That is, a string extracted from a file of an app containing a locale directory will go in a message file under that directory. By default django-admin makemessages examines every file that has the. If you want to override that default, use the --extension or -e option to specify the file extensions to examine:.
When creating message files from JavaScript source code you need to use the special djangojs domain, not -e js. To extract strings from a project containing Jinja2 templates, use Message Extracting from Babel instead. For more information, read its documentation about working with message catalogs. For example, if your Django app contained a translation string for the text "Welcome to my site. Long messages are a special case.
There, the first string directly after the msgstr or msgid is an empty string. Then the content itself will be written over the next few lines as one string per line. Those strings are directly concatenated. This means that everybody will be using the same encoding, which is important when Django processes the PO files. By default, fuzzy entries are not processed by compilemessages. To reexamine all source code and templates for new translation strings and update all message files for all languages, run this:.
Do this with the django-admin compilemessages utility. This tool runs over all available. In the same directory from which you ran django-admin makemessages , run django-admin compilemessages like this:. Django only supports. In some cases, such as strings with a percent sign followed by a space and a string conversion type e.
Or you can use no-python-format so that all percent signs are treated as literals:. You create and update the message files the same way as the other Django message files — with the django-admin makemessages tool. The only difference is you need to explicitly specify what in gettext parlance is known as a domain in this case the djangojs domain, by providing a -d djangojs parameter, like this:. This would create or update the message file for JavaScript for German.
After updating message files, run django-admin compilemessages the same way as you do with normal Django message files. This is only needed for people who either want to extract message IDs or compile message files.
Translation work itself involves editing existing files of this type, but if you want to create your own message files, or want to test or compile a changed message file, download a precompiled binary installer.
You may also use gettext binaries you have obtained elsewhere, so long as the xgettext --version command works properly. If you need more flexibility, you could also add a new argument to your custom makemessages command:. As a convenience, Django comes with a view, django. The view expects to be called via the POST method, with a language parameter set in request. Almost every company is a software company today, with multiple digital assets websites, web apps, IoT, etc.
Any internet business that is serious about going global should think about i18n internationalization and l10n localization. These are key processes that allow companies to adapt their digital assets into multiple languages and markets at scale.
Take a look at our comprehensive list of mobile app localization best practices , including an actionable checklist that you can share with your team. As Deloitte points out: to be successful, the bank of the future will need to embrace emerging technology. In fact, every single top finance app is available in more than one language. Their product is now available in over 30 languages, and they continue to add more. The link between language availability and success in fintech is evident, but many companies moving into new markets without a clear overview of localization face challenges in four main areas: compliance, quality, scalability, and accessibility.
Note: To learn more about overcoming these challenges from practitioners at Google, Remitly, Revolut, and more, download our ebook about localization in fintech. If a game is to be launched internationally and engage players around the globe, it first has to be properly localized.
Games, along with any interactive entertainment software, can contain complex narratives loaded with cultural references. As a result, game localization is a rather complex and delicate process. E-commerce is a global opportunity. That means localizing product descriptions, sizing charts, promotions and advertisements, providing your customers preferred payment options and currency, and so on.
Overall, proper localization ensures that your e-commerce website is not only translated but adapted to and functional in the target markets. Technology has transformed healthcare. Think of online medical consultations, using smartphones to monitor your health, digital care records, scannable wristbands with medication and patient data, or mobile apps used by patients in clinical trials.
Such technologies are aimed at improving patient care: making healthcare more accessible, while keeping the costs down. For medical companies operating in different markets, localization is often a requisite from a regulatory perspective.
The cost of errors in localizing medical content can be as high as a human life. As a result, working with specialized, certified linguists and performing rigorous quality assurance and compliance checks are key. If translation covers linguistic and cultural aspects, localization also includes visual and technical solutions. It makes the content fully functional in different languages, to ensure that your brand experiences resonate with your global customers.
In one of my previous articles I was covering Lokalise APIv2 basics, explaining its key features, and how to get started with it. Today we are going to work a…. Welcome to Humans of Lokalise. Stay tuned to get to know our team, one…. This month, we released a new project navigation, made enhancements to the glossary and launched a new Ruby library.
Read on to get the updates in…. But first, let us get clarity on the fundamental distinction between the two processes. Related posts Guides Localization. Insights Localization. That said, even marketing translation, which is more of a creative work, may benefit over time from using the TM technology: You can ensure consistency when translating slogans and catchphrases for a specific target market, for example, or if there is a specific terminology to talk about products and customers.
Let us review various types of content to understand how valuable a translation memory is when translating them. Take, for example, user guides for devices as different as phones and washing machines. Whenever a brand releases a new model, it does not produce a whole new manual: It reuses the content from previous guides maintenance instructions, warranty clauses, etc.
It only changes the pieces of texts explaining new or different functionalities. You can expect a lot of perfect and fuzzy matches in that kind of content. Nevertheless, when you do read them, it is easy to see how the same sections keep coming back from one set of terms and conditions to the next, from one report to the next.
These kinds of documents need to follow a specific format and cover the same grounds. So there you go again, a lot of repetitions that a TM would help translate that much faster. In a video game, a story unfolds with characters, places, and challenges.
The characters have names, vehicles, tools, possibly catchphrases. From one level to the next, from one game edition to the next—if successful—pieces of dialogues will also be repeated.
A TM will make it easy to store and then retrieve the translations so a character does not change names all of a sudden or start referring to their weapon with a whole new word. Consistency is key. Any piece of software, be it a web or mobile app, has names for menus, buttons, and other user interface elements. Once an element is translated, it is helpful for the translator to find it in the translation memory—and it makes for a much better user experience when the product is consistently localized.
Support portals or knowledge bases contain menus, instructions, and documentation, much like software or technical documentation when you think about it. Here again, the amount of repetitions warrants the use of a TM, especially when you know that the content will need to be updated and, therefore, retranslated. Expect another train of perfect and fuzzy matches!
This is yet again another type of repetitive content. Take a website offering online courses, for example. The description for each course will go through the same type of information: the course content, its goals, the audience, requirements to get the degree or completion certificate, etc. The same goes for an ecommerce website that will also follow a specific format with similar content to display the products.
They revolve around three major criteria for every business: quality, cost-savings, and time. This is a big one, and everyone involved can benefit from it. However, when two related translation projects are months apart, remembering how they translated that software menu item can be tricky.
They need to research their past translations, but that is not always a full-proof approach. Even if an editor is reviewing their work afterwards, the difficulty remains because the editor also faces the same memory challenge as a human being. If issues go unnoticed, the end-users will pay the price when faced with inconsistent translations that affect their experience.
This could soon turn into bad customer reviews which will then impact the brand. When an LSP is provided with a translation memory, they analyze the content to be translated to check for exact and fuzzy matches. They then usually apply discounted rates on these matches because they will require less work from the translators.
So, projects with content of highly repetitive nature can involve much less actual work than they first seem, leading to potentially massive cost savings. No surprise! A translator using a TM can perform their translation much faster when there are many matches. This will allow them to accept more projects and work for more customers, impacting their revenue positively.
As for a brand looking to translate their app or products, getting a faster turnaround will mean a quicker route to market and the increased ability to focus on other products to launch. Ultimately, it also means higher revenue for them. With most things in business, using good, reliable tools is the best way to get started on a project.
0コメント