Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate and pluralize by default locale #41

Closed
Leohige opened this issue Sep 18, 2017 · 7 comments
Closed

Translate and pluralize by default locale #41

Leohige opened this issue Sep 18, 2017 · 7 comments

Comments

@Leohige
Copy link
Contributor

Leohige commented Sep 18, 2017

I think it would be a good idea to use the translation of the models (if available) by default, for the menu and titles of each resource. Because pluralization only works well with English words.

Example, the plural of the word "Perfil" should be "Profis", but it will look like "Perfils". If this is implemented, the translations and pluralizations would be done by default, getting the translations correctly.

@spohlenz
Copy link
Member

I noticed this issue in your PR yesterday, so have begun doing a minor overhaul on how model names are used throughout the codebase. Should hopefully have something very soon.

@Leohige
Copy link
Contributor Author

Leohige commented Sep 19, 2017

If you have any ideas, I could help you implement this :)

@spohlenz
Copy link
Member

This has now been fixed in master (2ffe019). It'd be great if you could test it out.

@Leohige
Copy link
Contributor Author

Leohige commented Sep 20, 2017

It's working fine, but if some model does not have an 'other' key in translations, an error like this will occur:

translation data {:one=>"Perfil"} can not be used with :count => many. key 'other' is missing.

@spohlenz spohlenz reopened this Sep 20, 2017
@spohlenz
Copy link
Member

As I dive deeper into the i18n aspects of this, I'm finding it more and more difficulty to ascertain what the 'correct' way of pluralizing model names that works when a) there is no entry in the locale file, b) there is a single string entry in the locale file, c) there is a multiple-form entry in the locale file, and d) there is a multiple-form entry in the locale file with some entries missing.

I'd be curious to know why you don't have an 'other' key in this case -- is this because the plural form is the same as the singular, or are you expecting the plural form to be inferred from the Rails inflector rules for your locale?

@Leohige
Copy link
Contributor Author

Leohige commented Sep 22, 2017

I removed the 'other' key just as a way to simulate a specific situation, such as using the Rails inflector rules or not having the model translation. I think default pluralization should be done if the 'other' key does not exist.

You may also be able to check if there are any Inflector Rails rules for the default location (I don't know how to do it), and if not, default pluralization in English will be used.

@spohlenz
Copy link
Member

Further improvements have now been made in 370d01f. It will pluralize the singular form if only the singular is specified in the i18n file, and rescue and fallback as appropriate when other forms are missing.

I think that using English inflections if they are not provided for the current locale is possibly getting a little too smart (I like magic but I think this crosses a line that might cause too much confusion). In that case, either the singular and plural forms should be provided in the i18n file, or the inflections for that locale should be specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants