I recently make a decision to translate my tiny rails app with I18n gem as it described here.
While a testing, as it expected, I got a error messages from activerecord and devise:
translation missing: ru.devise.failure.user.not_found_in_database
translation missing: ru.activerecord.errors.models.user.attributes.name.taken
At this moment I know only one way to set up massages with custom locale - simply copy en.yml file which contains messages into my custom ru.yml, but it's weird way.
Maybe I missed something?
Cheers!
You can use the default option (related question)
I also advise you to look into the rails-18n gem for common translations
Devise provide common translations on their wiki
You can also set up a fallback locale to avoid missing translations (related question)
Related
Is there a tool (or built-in way) to see if a given translation entry is no longer referenced? Even a "mechanical" way would be helpful, meaning something which runs the test suite and reports which i18n entries were and were not hit. (I suppose it could report which translations are missing, too, but that's not what I'm after for the time being.)
I think the i18n-tasks gem has what you're looking for as it can find missing and unused translations. It also provides you with a spec template that will fail your suite if any locales have missing or unused translations (see Installation section on the README).
I have successfully installed the meta-tags gem for Rails and verified it.
Now, I am not sure how to modify my model/view/controller files to make use of the meta-tags gem. Specifically, I have an app with a Product model and 2 static Pages. I am trying to take strings from the Product db and dynamically populate the meta tags for Product view pages with those values. Then, I'd like to also set meta tags for the 2 static Pages.
Specifically, after adding
<%= display_meta_tags site: 'sitename' %>
I get the following error in localhost
undefined method `display_meta_tags'
I'm not sure where to set the meta tags and exactly what syntax to use in those files. I guessed it was the controller file for setting variables, but various trials of this haven't resulted in fixing the issue. I may, however, not have the correct syntax.
I tried searching, reading the meta-tags usage section, and reading this question, but neither had enough detail as far as where to put the various statements into my own m/v/c files. In addition, other blog posts show people using various workarounds to declare their variables more efficiently and I'm not sure which consistent set up to use.
I'm new to Rails, so apologies if I have overlooked something obvious. Thanks!
Resolved. Turns out I needed to restart my rails server. I figured this out by searching things related to 'undefined gem methods' and got this question --> Using Gems with Ruby On Rails: Undefined method?
I'm new to the gem-writing world, and I'm trying to make sure that my gem is as flexible as it can be out of the box. I've got a couple configuration options that will need to be set for things like testing, but I'd like for those options to be able to be overridden at the Ruby on Rails level.
I know that certain gems like Devise do this already, but I'm not sure exactly how it should be accomplished (primarily from the "put these files here, put those files there" kind of perspective). Can anyone give me any tips or suggestions?
Edit: What I'm really looking to know is how these gems manage having configuration settings defined locally to the gem and having them defined in Rails, and defining for the Rails application which takes precedence.
there are gems that help you create rails initializer style configuration.
an example is https://github.com/phoet/confiture/
I'm using devise gem to implement authentication in my Ruby On Rails application. Sometimes error messages are displayed such as:
Prohibited an error being wellness saved from this user: Password is
too short (minimum is 6 characters)
What is the best way to translate these messages to another language?
Go to config/locales and copy devise.en.yml, giving the file a name like devise.other_language_initials.yml. Then add your own translations.
For more info on how to translate your application, go here.
The fastest way is downloading a translation file to the language you want. You can find more about in this link.
What you are going to find there is a bunch of files in different languages for Devise flash notifications that you can download and add to you application under config/locales.
Hope that helps you! :)
I'm working on a Grails project that is internationalized (using the .properties resource bundles), and at the end of each release, we send a list of all the i18n messages that need to be translated. The problem is, there is no way to know which ones need updating/which ones are missing without manually tagging it (ie adding some 'magic word' at the end of each key). This seems very hacky and error prone.
What is common practice for keeping track of uninternationalized i18n labels?
Thanks.
Missing labels can automatically be detected by the ResouceCheck ant task. In particular, with the cross bundle check, it can inform you if a label is missing from any the properties for any locale.
For updated labels, I generally store the version number of the messages.properties that was last used as translation source in a header comment in each messages_xx.properties. Then a diff between the current messages.properties and the translation source version will show the properties that have changed and need to be retranslated.