googlevr / gvr-unity-sdk

Google VR SDK for Unity
http://developers.google.com/vr/unity/
Other
2.71k stars 1.09k forks source link

Cardboard Transition View on iOS in Incorrect Language #881

Open Moncader opened 6 years ago

Moncader commented 6 years ago

Summary: The system language is not used for the cardboard transition screen shown by Unity.

Found using:

Steps to reproduce the issue:

  1. Set the system language of an iOS device to Japanese
  2. Build an iOS cardboard app that uses the cardboard transition view.
  3. Enter VR mode and notice the messages are in English.

Additional comments: Other native apps seem to be using the correct language.

Performador commented 6 years ago

Unfortunately if your Unity XCode project does not declare that it was localized for a language, the GVR iOS SDK (embedded framework) will not be able to localize to that language.

One workaround is adding CFBundleLocalizations (Localizations) into your Unity projects info.plist and add the languages you would like GVR to localize to.

Will investigate if we can do this for you.

rusmaxham commented 6 years ago

@Moncader, could you try adding to your generated Xcode project's Info.plist file the CFBundleLocalizations key with this contents:

  <array>
    <string>en</string>
    <string>he</string>
    <string>ar</string>
    <string>zh</string>
    <string>zh_CN</string>
    <string>zh_TW</string>
    <string>fr</string>
    <string>de</string>
    <string>it</string>
    <string>ja</string>
    <string>ko</string>
    <string>en</string>
    <string>af</string>
    <string>ru</string>
    <string>bg</string>
    <string>ca</string>
    <string>da</string>
    <string>es</string>
    <string>et</string>
    <string>fe</string>
    <string>gl</string>
    <string>hr</string>
    <string>hu</string>
    <string>id</string>
    <string>lt</string>
    <string>lv</string>
    <string>ms</string>
    <string>nb</string>
    <string>nl</string>
    <string>pl</string>
    <string>pt</string>
    <string>ro</string>
    <string>sk</string>
    <string>sl</string>
    <string>sr</string>
    <string>sv</string>
    <string>tr</string>
  </array>
rusmaxham commented 6 years ago

We've got a build processor fix for this issue which will be in the next release.

Moncader commented 6 years ago

This worked. Thank you. And thanks for the update on the future release.

rusmaxham commented 6 years ago

You can add this snippet of code to GvrBuildProcessor.cs and replace OnPostProcessBuild to have this added every time you build from Unity:

  private readonly string[] SUPPORTED_LANGUAGES_IOS = {
    "ar", "ca", "cs", "da", "de", "el", "en", "en_AU", "en_GB", "en_IN", "es", "es_MX",
    "fi", "fr", "he", "hi", "hr", "hu", "id", "it", "iw", "ja", "ko", "nb", "nl", "pl",
    "pt", "pt_PT", "ro", "ru", "sk", "sv", "th", "tr", "uk", "vi", "zh_CN", "zh_HK", "zh_TW",
  };

  public void OnPostprocessBuild(BuildTarget target, string outputPath) {
#if UNITY_IOS
    // Add Camera usage description for scanning viewer QR codes
    // and localization languages on iOS.
    if (target == BuildTarget.iOS) {
      // Read plist
      var plistPath = Path.Combine(outputPath, "Info.plist");
      var plist = new PlistDocument();
      plist.ReadFromFile(plistPath);

      // Update value
      PlistElementDict rootDict = plist.root;
      rootDict.SetString("NSCameraUsageDescription", "Scan Cardboard viewer QR code");

      var localizations = rootDict.CreateArray("CFBundleLocalizations");
      foreach (var lang in SUPPORTED_LANGUAGES_IOS) {
        localizations.AddString(lang);
      }

      // Write plist
      File.WriteAllText(plistPath, plist.WriteToString());
    }
#endif
  }

This will make all of those languages appear in your App Store listing, so edit the SUPPORTED_LANGUAGES_IOS list appropriately for the language support your app will actually deliver.

fredsa commented 6 years ago

There's not a great way for the Google VR SDK for Unity to enable only the languages that the app developer wants to support.

In the mean time, customize the SUPPORTED_LANGUAGES_IOS and OnPostprocessBuild provided by @rusmaxham above.

Moncader commented 6 years ago

Yeah. After looking up how iOS language support works I think this isn't really the job of this SDK. Rather the developer just needs to write their own post process script to change it. You can close this if you please.

fredsa commented 6 years ago

Agreed. We are still investigating if there's more that we can do that would in fact be useful and wouldn't get in the way. If there's not a workable solution, we'll close this issue.