All Products
Search
Document Center

Mobile Platform as a Service:iOS language settings

Last Updated:Sep 07, 2023

It will introduce the method of setting language in the process of integrating mPaaS into iOS client.

When integrating with an iOS project, you can configure language settings for your iOS app.

Use the system language by default

  1. You can add Languages.bundle.zip to your project to configure languages supported by the current app.

  2. When the app is successfully launched, initialize the multilingual framework

    //#import <mPaas/APLanguage.h>.
    [APLanguageSetting sharedSetting];

Obtain the current app language

You can obtain the current app language by using the following command:

NSString *currentLanguage = [APLanguageSetting currentLanguage].name;

Modify the current app language

In the Languages.bundle file of the project, you can view the language currently supported by the app : You can modify the current app language by using the following command:

[APLanguageSetting setCurrentLanguageWithName:@"en"];

Support multilingual copywriting

  1. Add multilingual bundle files.

    1. Add the strings files corresponding to the languages currently supported by the app.

    2. Set the path that stores the multilingual files:

      [[APLanguageBundleLoader sharedLoader] setCustomLanguagesBundlePath:@""];
  2. Define text strings in strings files.

    The implementation principle of strings files is as follows:

    • The format of each text string in a strings file is as follows: The left side of the equal sign is the key of a text string while the expression on the right side is the content to be displayed in the corresponding language.

      For example : "BeeCityPicker : City Choice" = “City Choice”.

    • For the same text string, its key must be the same in all strings file. We recommend that you use a combination of the bundle name and the text string in Chinese as the key.

      For example : "BeeCityPicker : City Choice".

  3. Configure the text strings.

    For text strings that need to be provided in multiple languages, do not use hardcoded expressions. You can use the __Text macro. For example:

    self.navigationItem.title = __TEXT(@"BeeCityPicker",@"BeeCityPicker:City Selection", @"City Selection");
    • @"BeeCityPicker": The bundle name of a text string in a strings file. Generally, it is the name of a module resource bundle.

    • @"BeeCityPicker:City selection": The key of a text string in a strings file.

    • @"City selection": The content to be returned by default when the text string corresponding to a specified key cannot be found in the strings files.