Gvr-unity-sdk: Cardboard Transition View on iOS in Incorrect Language

Created on 20 Mar 2018  路  8Comments  路  Source: googlevr/gvr-unity-sdk

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

Found using:

  • Google VR SDK version: 1.120.0
  • Unity version: 2017.3.0f3
  • Phone manufacturer, model, and O/S version: Apple iPhone 8 Plus. iOS 11.2.6
  • Viewer manufacturer & model: N/A

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.

documentation bug iOS

Most helpful comment

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

```C#
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.

All 8 comments

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.

@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>

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

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

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

```C#
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.

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.

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.

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.

Was this page helpful?
0 / 5 - 0 ratings