mixed-reality-extension-sdk
mixed-reality-extension-sdk copied to clipboard
Support localized text and locales
Currently MREs don't know how to deal with different locales. We need to implement a system that makes it easy for MRE app developers to support. 99% of the cases are just about replacing text, but in some case users may want to replace textures, or do other custom solutions by locale/region (for example if you have a localized title screen, or if you want your blood to be “sweat” in some regions.)
We need each connected client (not user) to send up the locale to the server on join (if a client changes locale while MRE is running, the host app can just automatically rejoin the server, similar to how changing permissions will cause a server rejoin). Not sure exactly which properties to send up, but maybe language and region are independent? more research is needed
We should then come up with a system that abstracts this away from the MRE app developer in the 99% case - about text. I think the key piece is that the sync layer needs to be made localization-aware, and it needs to somehow look up the localized string for the right language for each connected client. Maybe the MRE itself should be able to register a callback that receives a string and a language, and returns a translated string – that way the app developer can translate however they wants. That would give the flexibility for devs to build a powerful system if they want to - managing dynamic loading of language resource tables for required locales, dealing with compound strings etc. At the same time it could default to just returning the source string, so there is no code needed for devs that don’t care about localization.
Example: displaying a “Hello World” string - User A on client device X is using English, User B on client device Y is using Danish
There is a table registered that says that the "!helloworld" identifier translates to “Hello World” in English, “Hej verden” in Danish, and there’s a callback registered that looks up the identifier based on the language. The code creates an actor the usual way, with the text component having a string identifier “!helloworld”. Sync Layer tells each client to create the actor. For each client device (X and Y), it asks the callback for the translation for !helloworld in English and German before it sends the data over. It would therefore tell client X to create the actor with text “Hello World, and client Y to create the actor with text “Hej verden”.