Reputation: 1107
I have strings that admin user can input into database. User can select language, I want to localize this text according to it. I do not want translate strings as I want to keep semantics same. Also I have researched but I have found examples for only static strings. Below question is relevant but I do not know string at compile time. User can insert any string.
Relevant stackoverflow question
Upvotes: 0
Views: 676
Reputation: 3769
If I understand your question correctly, there is no easy way to do this.
All UI localization tools are concerned with localizing texts stored in your application, like the text on a button, or an error message.
If your application shows texts from a database, this a completely different problem.
Normally, you would have to allow for a multilingual text in your database schema and give your admin user a way to enter a localized text. Probably, you would have to define a translations table with
In your application you would have to fetch the localized text from translations table.
If you use the original text as the key into the translations table, you will not have to modify the original table. If you use an ID, you would need to store this ID in the original table. Both have pros and cons.
If you are not too worried about the quality and consistency of the translations, you could use an online translation service. There are APIs for both the Google and Bing translator. Technically they are both paid services, but - at least with Bing - I think you have to pass a monthly threshold before they actually charge you anything.
Upvotes: 1