Blinks Language Localization
Adding Language code to requests for localizing texts
Localizing texts to the user’s preferd language gives a better ux, plus it facilitates onboarding non-english speakers.
Since the text of stuff is rendered on the server side, there are two ways we could have it done:
- The client tells the server what languages does the user’s computer has
- The server sends different JSON paths for every language it supports, and the client picks the one that matches the user’s browser setting
Addressing possible implementations for each:
1. Client tells the server the user’s languages
Adding a query parameter to the URL with the user’s language code.
https://host.com/blink/action?locale=en,es,fr
Which languages are available on JavaScript thru:
navigator.languages
//["en-US", "en", "fr"]
//or fallback, if navigator.languages is not available in the users browser
navigator.language
//"en-US"
2. Server sends multiple JSONs
For this option, it could be done in multiple ways:
a) Passing an object on keys that can be localized, where the key of every entry is the language code and the value the localized text.
{
...
"label" : { "es": "Coleccionar gratis", "en": "Collect for free" },
...
}
b) Having the entire JSON be in different keys, easier to maintain but it would not make sense for ** ActionPostResponse** that also have the transaction data, since you would have it repeated in both localized JSONs.
{
"en":
{
...
"label" : "Collect for free",
...
},
"es":
{
...
"label" : "Coleccionar gratis",
...
},
}
c) Having some sort of dictionary tags and a dictionary that has all the meanings of the tags, could be too much but adding it to the discussion.
{
...
"label" : "collect_for_free",
...
}
Dictionary would look something like this:
{
"en" : {"collect_for_free":"Collect for free"}
"es" : {"collect_for_free":"Coleccionar gratis"}
}
What are your thoughts? Solana is very global, we don’t want to have Blinks be in english-only all the time, do we?
Edit:
I think it should also apply to images, since in most cases we place text on images too. So letting define an URL or different URLs for images would be part of localizing it.