Button Mapping - I2 Local. with ''2'' languages
7 years 5 months ago #2332
by raraPapa
Button Mapping - I2 Local. with ''2'' languages was created by raraPapa
Hi!
I tried searching the forum with no luck.
I bought this plug-in with two objectives in mind:
1. Use it to localize our project. Which is pretty straightforward.
2. Use it to ''localize'' the images of the button in the game depending on which kind of controller is plugged in. For example, the end result I am looking for is to have some images switch when you plug or unplug a controller. More concretely, let's say in the tutorial there is a press ''A'' image with the ''A'' from Xbox, I want when I switch the ''language'' that the ''A'' becomes appropriate to the ''language'' of the other controller.
Is there a way to have two languages running at the same time? I would have one that is to set the language of the game and the other to set the input keys images.
Or is it possible to have two separate ''I2Languages'' prefab running along side? (again one for language, and the other for the input keys images).
Thanks!
I tried searching the forum with no luck.
I bought this plug-in with two objectives in mind:
1. Use it to localize our project. Which is pretty straightforward.
2. Use it to ''localize'' the images of the button in the game depending on which kind of controller is plugged in. For example, the end result I am looking for is to have some images switch when you plug or unplug a controller. More concretely, let's say in the tutorial there is a press ''A'' image with the ''A'' from Xbox, I want when I switch the ''language'' that the ''A'' becomes appropriate to the ''language'' of the other controller.
Is there a way to have two languages running at the same time? I would have one that is to set the language of the game and the other to set the input keys images.
Or is it possible to have two separate ''I2Languages'' prefab running along side? (again one for language, and the other for the input keys images).
Thanks!
Please Log in or Create an account to join the conversation.
7 years 5 months ago #2336
by raraPapa
Replied by raraPapa on topic Button Mapping - I2 Local. with ''2'' languages
Any input anyone? Thanks!
Please Log in or Create an account to join the conversation.
7 years 5 months ago #2339
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic Button Mapping - I2 Local. with ''2'' languages
Hi,
Sorry I haven't answered this yet. I read it a while ago in the phone, and I thought I already answered this, but I didn't, sorry about that!
As you said, that's the default, and will work out-of-the-box.
If I understood you correctly, you want to have 2 language Sources:
I2Languages.prefab with English, Spanish, etc (holding all the translations for your (1.)
and
ControllersSource.prefab with Xbox, PS4, Touch, Oculus, Vive, etc (holding terms like "Action"="A", "A"(PS4-style), "Swipe-up", etc, so, the action with the image that correspond to each controller.
In general that its not easily supported. You could do set something like that, by placing both prefabs, and adding the second one to the GlobalSources array so that it gets loaded. And then, have call GetTermData to get your the structure with all the languages so you could manually get the one you need.
But that seems like a bit over-doing to me.
My advise would be a far simpler solution:
Make each of your images to have the controller as a prefix:
instead of "A.png",
make them: "Xbox_A.png", "PS4_A.png", "Oculus_A.png", "Touch_A.png" (<- this last one can have a swipe-up image)
Then, in the Language source, just place the term translated to "{[A]}".
And add a callback to the Localize component that replaces {[A}] with the name of the image for the current controller.
e.g. {[A]} -> PS4_A
What will happen is that the localize component will get the translation "{[A]}" do the callback, and replace the translation with "PS4_A", and then automatically load that image and assign it to the Image or RawImage component.
Furthermore, you could even use Global or Local parameters to do that automatically and avoid having to add a callback to each of those Localize components.
This approach works great even when using TextMeshPro and having the image inside the text:
"Press {[A]} to jump"
Here is some information about Callbacks and Parameters:
inter-illusion.com/assets/I2LocalizationManual/Callbacks.html
inter-illusion.com/assets/I2LocalizationManual/Parameters.html
Said that, the plugin will be supporting more general Input Specialization in one the upcoming versions:
It currently only has Touch/Normal, but will extend to any one (even custom)
inter-illusion.com/assets/I2Localization...tSpecialization.html
Please, vote for that feature in the roadmap!
trello.com/c/slJ2P9aM/3-extend-input-specialization
Hope that helps,
Frank
Sorry I haven't answered this yet. I read it a while ago in the phone, and I thought I already answered this, but I didn't, sorry about that!
1. Use it to localize our project. Which is pretty straightforward.
As you said, that's the default, and will work out-of-the-box.
2. Use it to ''localize'' the images of the button in the game depending on which kind of controller is plugged in.
If I understood you correctly, you want to have 2 language Sources:
I2Languages.prefab with English, Spanish, etc (holding all the translations for your (1.)
and
ControllersSource.prefab with Xbox, PS4, Touch, Oculus, Vive, etc (holding terms like "Action"="A", "A"(PS4-style), "Swipe-up", etc, so, the action with the image that correspond to each controller.
In general that its not easily supported. You could do set something like that, by placing both prefabs, and adding the second one to the GlobalSources array so that it gets loaded. And then, have call GetTermData to get your the structure with all the languages so you could manually get the one you need.
But that seems like a bit over-doing to me.
My advise would be a far simpler solution:
Make each of your images to have the controller as a prefix:
instead of "A.png",
make them: "Xbox_A.png", "PS4_A.png", "Oculus_A.png", "Touch_A.png" (<- this last one can have a swipe-up image)
Then, in the Language source, just place the term translated to "{[A]}".
And add a callback to the Localize component that replaces {[A}] with the name of the image for the current controller.
e.g. {[A]} -> PS4_A
What will happen is that the localize component will get the translation "{[A]}" do the callback, and replace the translation with "PS4_A", and then automatically load that image and assign it to the Image or RawImage component.
Furthermore, you could even use Global or Local parameters to do that automatically and avoid having to add a callback to each of those Localize components.
This approach works great even when using TextMeshPro and having the image inside the text:
"Press {[A]} to jump"
Here is some information about Callbacks and Parameters:
inter-illusion.com/assets/I2LocalizationManual/Callbacks.html
inter-illusion.com/assets/I2LocalizationManual/Parameters.html
Said that, the plugin will be supporting more general Input Specialization in one the upcoming versions:
It currently only has Touch/Normal, but will extend to any one (even custom)
inter-illusion.com/assets/I2Localization...tSpecialization.html
Please, vote for that feature in the roadmap!
trello.com/c/slJ2P9aM/3-extend-input-specialization
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.
7 years 5 months ago #2342
by raraPapa
Replied by raraPapa on topic Button Mapping - I2 Local. with ''2'' languages
Thanks for the answer!
So I decided to go with the global parameters. I have a couple of questions.
Right now I tried with returning strings corresponding to a Term in my Language Source, but it doesn't seem to work out. Here is a detailed look at what I have:
----
A Canvas Image with a Localize script on it.
Localize script Target is set to ''Image''.
My term is linked to the text {[A]}
I have a script inheriting RegisterGlobalParameters.
In the GetParameterValue I have a switch looking for which controller type I have plugged in (and default case)
Then I have lines for each parameter:
if (ParamName == "A") return "PS4_A";
PS4_A is another term in my LanguageSource.
What is happening is that my globalparameter is returning a string and then tries to put it in a sprite. I would need to convert that string back to a term, like you do through the CallBackNotification.
Is there a function that I could use in my RegisterGlobalParemeter subscript to return a string that would replace the term?
Or should I modify the GetParameterValue function so that it can return Sprites?
I hope this is somewhat clear. Thanks for your help!
So I decided to go with the global parameters. I have a couple of questions.
Right now I tried with returning strings corresponding to a Term in my Language Source, but it doesn't seem to work out. Here is a detailed look at what I have:
----
A Canvas Image with a Localize script on it.
Localize script Target is set to ''Image''.
My term is linked to the text {[A]}
I have a script inheriting RegisterGlobalParameters.
In the GetParameterValue I have a switch looking for which controller type I have plugged in (and default case)
Then I have lines for each parameter:
if (ParamName == "A") return "PS4_A";
PS4_A is another term in my LanguageSource.
What is happening is that my globalparameter is returning a string and then tries to put it in a sprite. I would need to convert that string back to a term, like you do through the CallBackNotification.
Is there a function that I could use in my RegisterGlobalParemeter subscript to return a string that would replace the term?
Or should I modify the GetParameterValue function so that it can return Sprites?
I hope this is somewhat clear. Thanks for your help!
Please Log in or Create an account to join the conversation.
7 years 5 months ago #2355
by raraPapa
Replied by raraPapa on topic Button Mapping - I2 Local. with ''2'' languages
bump
Please Log in or Create an account to join the conversation.
7 years 5 months ago #2356
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic Button Mapping - I2 Local. with ''2'' languages
Hi,
Parameters and Callbacks can't change the translation into a Term. Instead, the modified translation is the one set into the targets.
In your case, you setup correctly the LocalParameter and its returning the corresponding string.
However, that string should be the name of the Sprite/Image and not the name of the Term holding the image.
For instance, your localParameters class when asked for "A" should return "PS4_A".
Then, the Localize component, takes that string ("PS4_A") and calls the DoLocalize_uGUI_Image function which tries first to convert that text into an image by:
- looking in the Referenced assets of the Localize component
- if not found, it looks in the Assets section of the I2Languages.prefab
- if not found then it looks in the Resources folder.
So, if you have a Sprite named "PS4_A" in your Resources folder, then the UI.Image component will load it and use it.
If you don't want to add those sprites to the Resources folder, you should add them to the Assets section of the I2Languages.prefab or Localize component. That way they will be referenced and found correctly.
Hope that helps,
Frank
Parameters and Callbacks can't change the translation into a Term. Instead, the modified translation is the one set into the targets.
In your case, you setup correctly the LocalParameter and its returning the corresponding string.
However, that string should be the name of the Sprite/Image and not the name of the Term holding the image.
For instance, your localParameters class when asked for "A" should return "PS4_A".
Then, the Localize component, takes that string ("PS4_A") and calls the DoLocalize_uGUI_Image function which tries first to convert that text into an image by:
- looking in the Referenced assets of the Localize component
- if not found, it looks in the Assets section of the I2Languages.prefab
- if not found then it looks in the Resources folder.
So, if you have a Sprite named "PS4_A" in your Resources folder, then the UI.Image component will load it and use it.
If you don't want to add those sprites to the Resources folder, you should add them to the Assets section of the I2Languages.prefab or Localize component. That way they will be referenced and found correctly.
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.206 seconds