API calls without first using Localize component
10 years 2 months ago #333
by Jos
API calls without first using Localize component was created by Jos
Hello!
I'm using my own components, which make use of the I2.Loc.LocalizationManager.GetTermTranslation() method.
If i don't have an instance of the Localization component on a TextMesh someplace in my scene, any calls to 'GetTermTranslated()' fail, returning empty strings. However, if i DO have an Localization instance in my scene, it seems to work fine.
Is there some init-ing which the Localization component does, which the call to GetTermTranslation() doesn't?
Thanks!
I'm using my own components, which make use of the I2.Loc.LocalizationManager.GetTermTranslation() method.
If i don't have an instance of the Localization component on a TextMesh someplace in my scene, any calls to 'GetTermTranslated()' fail, returning empty strings. However, if i DO have an Localization instance in my scene, it seems to work fine.
Is there some init-ing which the Localization component does, which the call to GetTermTranslation() doesn't?
Thanks!
Please Log in or Create an account to join the conversation.
10 years 1 month ago #334
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic API calls without first using Localize component
Hi,
That issue is fixed on 2.3.1 which I should be releasing in the next days.
A quick tweak to have it working while the version new version gets released is to add the InitializeIfNeeded function and add a call it on the GetTermTranslation
Like in:
That way you can retrieve the localization without using the Localize component in your scenes.
Other way to do it, its by selecting the language before calling GetTermTranslation. That will trigger an initialization as well.
Thanks,
Frank
That issue is fixed on 2.3.1 which I should be releasing in the next days.
A quick tweak to have it working while the version new version gets released is to add the InitializeIfNeeded function and add a call it on the GetTermTranslation
Like in:
static void InitializeIfNeeded()
{
if (string.IsNullOrEmpty(mCurrentLanguage))
{
RegisterSceneSources();
RegisterSourceInResources();
SelectStartupLanguage();
}
}
public static string GetTermTranslation (string Term)
{
InitializeIfNeeded();
for (int i=0, imax=Sources.Count; i<imax; ++i)
{
string val = Sources[i].GetTermTranslation (Term);
if (!string.IsNullOrEmpty(val))
return val;
}
return string.Empty;
}
That way you can retrieve the localization without using the Localize component in your scenes.
Other way to do it, its by selecting the language before calling GetTermTranslation. That will trigger an initialization as well.
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
The following user(s) said Thank You: Jos
Please Log in or Create an account to join the conversation.
- alice_funo
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
7 years 9 months ago #2190
by alice_funo
Replied by alice_funo on topic API calls without first using Localize component
This issue crept up on me because I'm calling LocalizationUtils::GetLocalizedString(string term, LanguageCode regionCode), which does GetTermData, which doesn't have the "InitializeIfNeeded" function.
Adding it will make it work. Just pointing it out so maybe there will be a more official fix
Adding it will make it work. Just pointing it out so maybe there will be a more official fix
Please Log in or Create an account to join the conversation.
Time to create page: 0.184 seconds