I have the following problem, I'm using the standard i18n to translate to spanish all the website (:es), but now I want to change model label that depends on regions and not only language.
So I want to use es-MX,es-AR,es-PA and so on but in the documentation it says that rails doesn't support regionalization.
Some examples of regionalization:
For some model labels I use: DNI (identity document) but in mexico the correct label is IFE.
So is there a way to add support for es-MX, es-AR and other regionalizations
If you look here https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale then you will see that the regions you want are present here as separate languages. You can do what you want the same way. Just use each region as a separate language. Good luck !
Related
I have an app that is used to track/manage livestock. It currently supports one species, Sheep. We want to begin supporting multiple different species, like Goats, and Cattle. My first thought was to create something similar to NSLocalizedString(text, comment) like SpeciesString(text, species, comment) which would take the English string and the species name and translate the Sheep term Ram to the Cattle term Bull. And internal to that, I could use NSLocalizedString() to then further translate that to the proper language so that in the future I could support multiple languages as well.
I see that I can pass a tableName to NSLocalizedString() so that it will use a different file other than Localizeable.strings and that would allow me to programmatically pull values from a Spanish language file that is focused on Cattle instead of Sheep (something like Localizeable-sheep.strings and Localizeable-cattle.strings), but that won't help me with all of the text that is in the storyboard.
I know that there is built-in support for localization with the storyboard, but the problem I'm having is that when the text comes to my code, for example in viewDidLoad, it will already have been translated to the other language, for example Spanish. I would prefer to find a way to make the text in my views already have the right Language+Species combination by the time it gets to my code. But even if I did rely on programmatically swapping out the strings to use the right Species, the English will already been changed to Spanish and I'll get Carnero instead of Ram and if I try to pass that through to my SpeciesString() it won't match my underlying data, because my underlying data is keying off of the English version of the text.
Is there a way to create a custom language? I've seen this code that is used to change the localization language on the fly, and it works for swapping between en and es, but I can't create my own fake languages like en-sheep and es-sheep.
Is there either:
a) a way to create my own custom language so that the localization system will just pick my correct Language+Species combination?
or
b) a way to tell the Storyboard which table name/filename to pull strings from? So that instead of just having a strings file for my Main.storyboard be called es.lproj/Main.strings but I could instead have
es.lproj/Main-sheep.strings and es.lproj/Main-cattle.strings?
I think my inability to get my "custom language" to work was just an accidental oversight. I created an es-sheep.lproj/Main.strings and used the other SO post to programmatically set my language to es-sheep and it didn't seem to work...
... but it turned out that I had created those directories and files, but forgotten to add them to the project. Once I manually added them to the project, it started working and I was able to use my custom localizations.
I received a translation for a software in plain german ("einfaches deutsch"). I am really happy about this because I think accessibility is really important. However, in order to integrate it, I need a code for that language.
I usually use 2-letter ISO codes for that, e.g. en or de. I already knew that you could add a territory code like en-US or de-AT. By reading RFC5646 I found out that what I am looking for is probably a variant subtag like de-simple.
However, these variant subtags need to be registered with IANA. I browsed the language subtag registry there and did not find any variant subtag that matches what I was searching for. So it seems like there is no variant subtag for plain language.
So I see three options here:
I missed something.
I just go ahead and use an unofficial language code such as de-simple.
I register the simple subtag with the IANA.
Which one is it?
There is currently no language tag for simple languages. It has been discussed but there were to many open questions. The best option for now is probably to use a private use subtag, e.g. de-x-simple.
In the meantime, a -simple variant tag has been standardized, so now it is possible to use de-simple. See this blog post for details.
I would suggest that you simply use the language tag on its own. i.e. lang="de" because this is supposed to be the non-specific language tag - which correlates pretty much with "einfaches Deutsch".
If you read the definition of "Leichtes Deutsch" then you will see that it is a style of speaking/writing that is independent of dialect or variant. It is like a style of writing in the same sense that Shakespeare has a style of writing and Dr. Seuss has a style of writing.
In either case, the RFC states quite clearly that subtags must be registered before being used
Variant subtags MUST be registered with IANA according to the
rules in Section 3.5 of this document before being used to form
language tags. In order to distinguish variants from other types
of subtags, registrations MUST meet the following length and
content restrictions
In general when we talk about localization we mean en, ja, fr and so on...
Please look at http://www.siselean.com/ and click on the Select Market vertical button located on the left side of the page.
Countries are listed. When you click on any of them, each at least has 2 languages.
Also pay attention to when you select a language, in the address bar it shows its respective locale such as http://www.siselean.com/?locale=fr_CA
If you click on Canada, for example, it has French and English versions of the page.
Here at http://middlemanapp.com/advanced/localization/ it's showing the classic way:
locales/en.yml:
en:
hello: "Hello"
locales/es.yml:
es:
hello: "Hola"
The question is how to create locales en_CA and fr_CA in this case?
Middleman's i18n engine only works with lanugages, not countries.
For a menu, you will have to create a custom helper and/or partial that maps your languages to country-language pairs.
For custom URLs, the Middleman-Blog extension might come in handy. Be aware that its i18n configuration is different from that of vanilla Middleman.
Middleman-Blog serves as a poor man's database engine. You can create per-country pages that share common layouts but different content and frontmatter.
You can also store stuff in Yaml data, categorize it in country-language fashion and use a custom helper to retrieve it.
I am at the end off my project. I implemented few languages.
But this moment, I have categories that are placed in database, but these categories are in my native Latvian language, what would be the trick to be able change language of these records simultaneously with display language change.
It means that If I choose locale en, then these category names are displayed in english.
Some ideas!
To store ultiple language translation within the records, I think it's bad idea.
Or to store just put latvian category name as id inside <%= I18n.t 'category_id_in_latvian'%>
and just in yml files put the translation ?
Or there are other solution?
Thanks
You should take a look at the Globalize Gem:
Github of globalize3 Gem
This gem should do exactly what you need. ;)
And if it doesn't, please, explain why by providing more details on what you want to do and I'll update my answer according to your needs.
I want to have Greek support in my rails app for the messages/flashes etc. I took a quick look at the I18n framework but it seems like a lot of configuration for something so simple. I thing that there should be a very easy way to do something like this but ( apparently ) I don't know it. If anyone would be willing to help me I'll be glad. Thanks.
Rails has conventions so you don't have to configure.
Create a file in config/locales/el.yml with the contents:
el:
flash_messages:
success: "επιτυχία"
fail: "αποτυγχάνουν"
Then in your controller:
flash[:notice] = t('flash_messages.success')
and you'll get the translated string in your view.
You can change the locale like this:
I18n.locale = :el
I don't know how it could be easier. The "Rails I18n Guide":http://guides.rubyonrails.org/i18n.html has all the gory details if you want to fight the conventions or go beyond simple.
I18N ain't simple.
Here are some of the reasons why internationalization is hard.
First, every piece of text that might be shown to the user is a potential candidate for translation. That means not just properties of components (like menu items and button labels), but also text drawn with stroke drawing calls, and text embedded in pixel images (like this one taken from the MIT EECS web page). Translation can easily change the size or aspect ratio of the text; German labels tend to be much longer than English ones, for example.
Error messages also need to be translated, of course — which is another reason not to expose internal system names in error messages. An English-reading user might be able to figure out what FileNotFoundException means, but it won’t internationalize well.
Don't know Ruby so I can't help you more.