What are the best Rails inflection rules for the German language out there? Examples from other languages to be ported would be great, too.
In my experience looking for a complete set of German inflection rules is hopeless. Even the default ones (English) are incomplete.
Here's what I do in my Rails applications.
Only use pluralize and Co. for code identifiers.
For model names (and all "user facing" strings) use the I18n API even if there's only one language.
Configuring the I18n stuff is slightly more work to set up, on the other hand your code is no longer cluttered with end-user messages.
Related
I am trying to wrap my head around what localization means here. I've been reading these docs:
Internationalization is a complex problem. Natural languages differ in
so many ways (e.g. in pluralization rules) that it is hard to provide
tools for solving all problems at once. For that reason the Rails I18n
API focuses on:
providing support for English and similar languages out of the box
making it easy to customize and extend everything for other languages
As part of this solution, every static string in the Rails framework -
e.g. Active Record validation messages, time and date formats - has
been internationalized, so localization of a Rails application means
"over-riding" these defaults.
What does that mean? What does localization mean here?
I think this makes sense:
The default en.yml locale in this directory contains a sample pair of
translation strings:
en: hello: "Hello world" This means, that in the :en locale, the key
hello will map to the Hello world string. Every string inside Rails is
internationalized in this way, see for instance Active Model
validation messages in the activemodel/lib/active_model/locale/en.yml
file or time and date formats in the
activesupport/lib/active_support/locale/en.yml file. You can use YAML
or standard Ruby Hashes to store translations in the default (Simple)
backend.
The I18n library will use English as a default locale, i.e. if you
don't set a different locale, :en will be used for looking up
translations.
In the bolded statement,
validations have been "internationalized" (read: supports customization for localisation)
so localization of a Rails applica.... (read: the activity of localising your application is by means of overriding the default values provided by the built in internationalization functionality.)
Will revise my answer if it doesn't help.
I'm quite familiar with how Rails handles internationalisation with regards multiple languages and formatting of dates, currencies and alike.
Extending this idea, is there way to do this with custom sets of vocabulary that are not different languages or regional settings.
For example, in an app which is used by orgnisations, you might have tools to allow "employees" to communicate with their "managers". Is there a way to substitute the vocabulary for, say, "students" and "teachers", on, an organisation-by-organisation basis, while leaving the model, controller and view code all intact?
You can just use standard i18n localisation.
The Rails guide even gives examples for adding the Pirate language: http://guides.rubyonrails.org/i18n.html#adding-translations
Create your per-organisation languages and set the locale appropriately.
Assuming you need your i18n translations to be a little more dynamic, you may wish to take a look at one of the DB backend gems for i18n. Such as this one: https://github.com/svenfuchs/i18n-active_record
I am creating a website structure which will allow for multiple "language packs" for verbiage across the site.
I have look into internationalization, but I'm not sure it's the route will work because all the different language packs will be in English. It would just be re-wordings, essentially.
Can internationalization (with resource files) work for this, or is there a better option out there?
Internationalization should work because it does factor in locale. Even if the language is the same, the locale is different. Eg en-gb
Take a look at this post. Note the section where the post talks about the differences between spanish in mexico and spanish in spain.
http://www.hanselman.com/blog/GlobalizationInternationalizationAndLocalizationInASPNETMVC3JavaScriptAndJQueryPart1.aspx
While I have experience developing Rails apps in English, I am a blank slate when it comes to handling globalization, so please don't shoot me in the head if my question 'doesn't make sense' :)
I have been asked to add multi language feature to a part of a Rails app that I am working on. Initially its only going to be 2 languages, French and German. The content that will be translated (which is in English now) is rendered using partials at the moment hence I am getting a bit inclined on creating partials with different languages and then based on the users language selection call the relevant partial - Would you recommend this approach?
Although it seems a heavy weight solution for this particular purpose, but I am also looking at the Rails Globalize plugin. This seems to appeal if I look at the long term gains, something like what if later I am asked to translate the entire app.
Any insights on what would be a proper structured approach to handle globalization in Rails?
Many Thanks
Have you had a look at the i18n (internationalization) API that is in Rails itself as of 2.2? It makes it easy to store your language translation files as .yml files, so a fr.yml and a de.yml or whatever. It also steps through different approaches of making languages accessible via browser prefs, or URLs, subdomains, etc. In your HTML template files you use symbols to specify the keys for the string you've translated. At least in my basic usage and testing, it was very easy to work with.
I preffer using translator instead of Rail's i18n, since the former handles "scoping of translation" automatically. I recommend you give it a look.
This is a great article on how to use Ruby's GetText to localise you Rails App.
I'm creating a fast application with ruby on rails, and after doing a lot of scaffolding and validation I'm very happy with some of the features that are embeded in RoR... but I live in Mexico and all my users would love the application to be in Spanish of course. So, I noticed theres a lot of functions that write actual text in English for example time_ago_in_words and all the errors produced by the scaffolding and validation.
Before actually doing those things on my own (like I would in php for example) I wanted to know if theres some kind of language file I could edit (or even download one in Spanish). After all, the books I'm reading and the tutorials (and webcast) I'm following to learn this new framework are all in English (and fail to include this problem).
Here you can find a nice sample app which demonstrates some basics of i18n (internationalization features) in Rails.
This guide contains the most recent work on internationalization. A pretty decent reference:
http://guides.rails.info/i18n.html