Localise one word only instead of everything

More
8 years 5 months ago #1525 by Nelz01
Hey Guys

Is there a simple way to localise one word at a time, instead of everything?
eg. press a button and only 1 specific text component will be translated

Any help would be greatly appreciated
Peace!

Please Log in or Create an account to join the conversation.

More
8 years 5 months ago #1527 by Frank
Hi,
If you need to localize a single Localize component every time you touch a button, you should just change its term and call the Localize function.
public Text _LabelObj;    // This is a reference to the Label that you where you want to show the localization. It should also have a Localize component

public void OnClick()
{
      var localize = _LabelObj.GetComponent<I2.Loc.Localize>();   // Get the localize component
      localize.SetTerm("NewTerm");    // Finds the translation of the term: "NewTerm"  and shows that in the _LabelObj
}


Alternatively, you can manually do the translation instead of using the Localize component.
public void OnClick()
{
     _LabelObj.Text = I2.Loc.ScriptLocalization.Get("NewTerm");    // Gets the translation and assigns it to the label
}

The drawback of this last way, is that you wont be able to get all the benefits of the Localize component (e.g. Using callbacks, Modify the translation to Capital or Tittle Case, if the user change the language the translation wont change, etc)

Also, here you can find more detail about the localization API.
inter-illusion.com/assets/I2Localization...yusedScriptAPIs.html

Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
8 years 5 months ago #1529 by Nelz01
Hi Frank

Thx for the help. This worked pretty well, however the issue is I only want to change the language, not the term.

I've tried including "I2.Loc.LocalizationManager.CurrentLanguage = "Portuguese"; " into the OnClick() you supplied but it still changed everything.

Please Log in or Create an account to join the conversation.

More
8 years 5 months ago #1530 by Frank
Hi,
Changing the CurrentLanguage will automatically trigger a LocalizeAll event, so that every visible label/sprites/etc is changed to match the language you are setting.

If you want to get the list of all Languages in their corresponding language, here are some info.
inter-illusion.com/forum/i2-localization...ages-translated#1254

If instead, you just need to get the translation of some term into an specific language (which is not the CurrentLanguage), then you can do:
var I2langPrefab = I2.Loc.LocalizationManager.Sources[0];

var termData = I2langPrefab.GetTermData("Example Term");
var languageIdx = I2langPrefab.GetLanguageIndex("Portuguese");

var translation = termData.Languages[languageIdx];

That code will get you the translated value of "Example Term" into the "Portuguese" language.

Hope that helps, But if that's not exactly what you need, please give me a bit more detail about what you are trying to accomplish and I can write a function for you to get the data you need.

Thanks,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
8 years 5 months ago #1531 by Nelz01
I am trying to make a Language game where you choose two different languages.
When you choose language "A" every label with a certain tag will be localized to that language. The same would apply to language "B".

I know its not what I originally asked, I just figured if I could isolate one object, I could apply the idea to more than one.
Sorry for the hassles bro! not sure if Im asking too much :unsure:

Please Log in or Create an account to join the conversation.

More
8 years 5 months ago #1532 by Frank
Hi,
Here is an script that will allow you doing that:
inter-illusion.com/forum/i2-localization...age-term-by-term#534

Just add the AlternativeLocalization component to any GameObject with a Localize component, and it will override the language to be English.
It basically uses the localizationCallback. On startup it registers itself as a callback, and then, whenever the Localize component tries to localize itself, it will call the OnModifyLocalization function which will get new translations for English.

You can change English to any other language.

Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

Time to create page: 0.235 seconds
Template by JoomlaShine