Dynamic localization using i18n package
Asked Answered
P

2

8

I am trying to localize all the text of a web page using the i18npackage. My requirement is to convert all the text in to the selected locale.

Is it possible to localize dynamic text, such as user input, like name, designation in a form into the selected locale? If so, how can I do it?

Perish answered 16/6, 2020 at 9:37 Comment(2)
Does a translation for the input text already exist in the i18n message repository? If not would you explain further what you intend.Aveyron
i18n does not translate for us (IMO) it actually retrieve values from the already set object based on defined locale. But if you can use google translate to first get your desired language string and set the value in i18n translation repo , than helpSchramke
U
3

The idea of localization is to translate information text, input labels, and all the static texts so users from any part of the world can understand. In my opinion, we should not translate the input provided by the user.

You can try out here: https://www.w3schools.com/HOWTO/tryit.asp?filename=tryhow_google_translate

Add the input field like below. Even Google will not translate the input provided by the user.

<input type="text" value="HELLO" />

I have a system where I have applied localization. Users from Germany, Netherlands, India, and USA are using the website. We have translated only static text that helps users in understanding the information or labels of input.

Regarding user input, users can provide input in their preferred language. You can store them in the Database as it is using Unicode. So when you will fetch the data it will be the same. But the idea of translating user input is not good.

Let me know if this helps or do you still want to translate then I can provide you a function which will do the translation?

Unopened answered 21/6, 2020 at 6:36 Comment(0)
N
2

I agree with @VivekPatel's answer but I'd like to broaden it. Also, you don't give too much context so it is a bit harder to decide however, this is what I would do:

  • Dynamic texts that are not changing often and can be done by dedicated operator(s) could be translated using a CMS system where the operator has to provide the texts, titles, images in each of the languages. Most CMS systems you can find out there will support this out of the box or can be easily added with plugins. It is useful when you have a webshop and to translate the product name, descriptions etc. Or in a scenario where you have changing content like banners, commercials.
  • In the case of user input where it actually makes sense to translate you could use a third-party translation service like amazon or google translate. Scenarios like this I can imagine would be comments or blog posts etc. In this case, the costs can go high if you have a website that is used by a lot of users and it makes sense to only translate one string once and store the translations in your own database.

Both solutions require extra setup of course and I don't think it would be solved by the package you linked.

Numidia answered 25/6, 2020 at 9:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.