Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

explicitly tell into what language to translate

I have as usual my translation files in locales.

Now I have an invitation mail in various languages.

I want the user to select in what language the mail should be sent, because it's not about the language of the operating user, it's about the language the mail receiver should read.

Is there a way to tell rails explicitly what language to pick, like t(:my_string, :en)?

The goal is, to have it temporary translated for only one single call of t.

This is what I need, to tell within the t() command, what language is to be used.

like image 570
Joern Akkermann Avatar asked Aug 27 '11 12:08

Joern Akkermann


People also ask

What is implicit translation?

Things which are understood by the speaker and hearers (or writer and readers), and are part of the meaning of the text, but which are not actually stated in words in the communication are implicit.

What is translation process in language?

Translation is the process of reworking text from one language into another to maintain the original message and communication.

What is translation target language?

Definition of target language 1 : a language into which another language is to be translated — compare source language. 2 : a language other than one's native language that is being learned.


2 Answers

It's possible to pass :locale option to t method:

  t :my_string, locale: :de
like image 122
Anton Styagun Avatar answered Sep 25 '22 06:09

Anton Styagun


I think you will explicitly need to set proper language to I18n.
You can use: I18n.locale = :en to set language you need.
Also look here: I18n

like image 31
bor1s Avatar answered Sep 22 '22 06:09

bor1s