berk / tr8n

This repository has moved to:
https://github.com/tr8n/tr8n
MIT License
279 stars 37 forks source link

Can't crowdsource attribute translations #46

Closed jamesarosen closed 12 years ago

jamesarosen commented 12 years ago

This template

<%= link_to tr('go fishing'), 'http://fishing.example.org',
            :title => trl('The best fishing site') %>

produces this HTML (for non-default-language users)

<a href="http://fishing.example.org"
   title="The best fishing site">
  <tr8n class='tr8n_translatable tr8n_not_translated'
        translation_key_id='173'>
    go fishing
  </tr8n>
</a>

Right-clicking the link brings up the translation for key 173. There's no way for the user to translate 172 (the title attribute).

berk commented 12 years ago

Users can translate the key 172 in the bulk translation mode by going to: /tr8n/phrases or you could add another helpful tag:

<%= tr8n_phrases_link_tag("The best fishing site") %>

which will link them directly to the phrase, but only if the inline translations are enabled.

The tr8n_phrases_link_tag is also useful when you deal with lists of data:

<%= select_tag(:items, tr8n_options_for_select(["milk", "bread", "cheese"], "cheese", "Shopping item")) %> <%= tr8n_phrases_link_tag("Shopping items") %>

Notice that this time i am making the link to all of the phrases by using the items description. When user enables inline translations, they will have a little icon next to the drop down box that will take them directly to the phrases in the list.

jamesarosen commented 12 years ago

Great tip! I'll try to add this to the documentation.

taimoor commented 10 years ago

Good to know above mentioned things @berk . But when I use tr8n method in my helper file then it don't translate strings used in helpers methods of rails app.

berk commented 10 years ago

@taimoor try switching to the Tr8n Client SDK instead of Tr8n gem. In the SDK i will be adding support for i18n standard fallback mechanism. So all t() methods will go through tr() backend. Along with many other new features, like ongoing Rails 4.0, 4.1 support, new TML syntax, better UI tools, etc...

https://github.com/tr8n/tr8n_rails_clientsdk

I will give you a script to migrate all your translations to the service.

taimoor commented 10 years ago

Thanks for suggesting a solution. So can you give me script so that I can transition to your suggested changes at local setup of project.