這個(gè)問題提坑了我一天,實(shí)際上早已有了解決方案,而且官方文檔也已經(jīng)給出了答案,這里有兩個(gè)方法:
實(shí)際上是一個(gè)方法,只是方法一是通過xcode來修改,方法二直接修改plist文件,方法二更直接簡(jiǎn)單,不用打開xcode
方法一
iOS applications define key application metadata, including supported locales, in an Info.plist file that is built into the application bundle. To configure the locales supported by your app, you’ll need to edit this file.
First, open your project’s ios/Runner.xcworkspace Xcode workspace file then, in the Project Navigator, open the Info.plist file under the Runner project’s Runner folder.
Next, select the Information Property List item, select Add Item from the Editor menu, then select Localizations from the pop-up menu.
Select and expand the newly-created Localizations item then, for each locale your application supports, add a new item and select the locale you wish to add from the pop-up menu in the Value field. This list should be consistent with the languages listed in the supportedLocales parameter.
即需要聲明應(yīng)用需要支持國(guó)際化官方文檔
方法二
更簡(jiǎn)單的方法是直接打開your_project/ios/Runner/Info.plist,然后加入
<key>CFBundleLocalizations</key>
<array>
<string>English</string>
<string>pt</string>
<string>es</string>
<string>ja</string>
</array>
修改之后如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleLocalizations</key>
<array>
<string>English</string>
<string>pt</string>
<string>es</string>
<string>ja</string>
</array>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
.
.
.
other lines

image