How to change cordova-camera-plugin language in iOS?
Asked Answered
E

2

11

I wish to change the cordova-camera-plugin language. Apparently it is dependent on a variety of things. My development environment is Tools for Cordova in Visual Studio 2015. It is unlikely that it matters but I am using the Ionic framework in my app. We build our app for iOS on a MacBook Pro laptop running Xcode 7. The device I am testing on is an Ipad running iOS 9.1 with Dutch as first language and english as second.

In my app when you open the camera you have a few options such as Cancel, Use Photo and Retake Photo.

The things I have done to try and make the plugin localized to the Dutch language are the following.

In config.xml I have changed the following line to

<widget xmlns:cdv="http://cordova.apache.org/ns/1.0" 
xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps" 
id="hop.test1" 
version="1.0.1" 
xmlns="http://www.w3.org/ns/widgets" 
defaultlocale="nl-NL">

And in my /platforms/ios/projectname/projectname-Info.plist I have added the following lines:

<plist version="1.0">
  <dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>nl</string>
    <key>CFBundleLocalizations</key>
    <array>
      <string>nl</string>
    </array>
  <!-- other values omitted !-->
  </dict>
</plist>

nl appears to be the correct localization notation for dutch based on my search results around google and stackoverflow.

The problem is that when I build my app and test the camera, the camera buttons are still written in english. Have I implemented something wrong, am I missing some values somewhere or is this the wrong way to go about localizing a plugin in cordova?

El answered 15/12, 2015 at 10:18 Comment(2)
Please see if this helps.Arboriculture
@Arboriculture It did help me with a bit more insight on how this all works. However, the solutions provided there don't seem to work for the dutch language. issues.apache.org/jira/browse/CB-9789 Is labeled as not an issue. So apparently I am doing something wrong in the iOS project.El
A
0

For the records, it is working now (year 2020) :

Setting the <widget defaultlocale="fr"> of the config.xml successfully update the CFBundleDevelopmentRegion of the xcode project.

And therefore the expected locale (fr) is correctly used in the camera.

Arsenic answered 7/1, 2020 at 9:22 Comment(1)
How can I proceed with this if I want to have multiple languages?Sigfrid
C
13

Just make the settings in Xcode. They will not be overwritten after you make another cordova build:

enter image description here

UPDATE:

If you don't have the entry «Localization native development region», then:

– Go to info -> select your target

– Right click on an existing key entry and choose Add Row

– Type «Localization …», when Xcode autocompletes your input, then select under value your language.

Cally answered 3/1, 2016 at 7:26 Comment(7)
Thanks, I had to find the xcodeproject that TACO sends to the mac laptop and thanks to our intern we could find the hidden folder. This works. And changing the infoplist file manually doesn't.El
Xcode project will me removed or overwritten in a lot of cases, this solution is not good. The best option is to use a plugin or a hook that writes on the info.plist file.Chatwin
<3. I have nothing more to say.Anxiety
Does this make the camera plugin use the device language? I still get English despite the device language is set to Spanish or ItalianGuinna
@Mirko where you by any chance able to get the camera plugin work based on the users phone language ?Dreamland
@user581157, I added <array> <string>en</string> <string>it</string> <string>es</string> </array> to the 'plist' file under CFBundleLocalizationsGuinna
@Mirko after adding this get compilation error: ... Prepared iOS project successfully doc.find is not a function TypeError: doc.find is not a function at Object.resolveParent (/Users/admin/.nvm/versions/node/v10.24.0/lib/node_modules/cordova/node_modules/cordova-common/src/util/xml-helpers.js:201:26) at /Users/admin/.nvm/versions/node/v10.24.0/lib/node_modules/cordova/node_modules/cordova-common/src/ConfigChanges/ConfigChanges.js:347:53 at Array.forEach (<anonymous>) at is_conflicting ...Siccative
A
0

For the records, it is working now (year 2020) :

Setting the <widget defaultlocale="fr"> of the config.xml successfully update the CFBundleDevelopmentRegion of the xcode project.

And therefore the expected locale (fr) is correctly used in the camera.

Arsenic answered 7/1, 2020 at 9:22 Comment(1)
How can I proceed with this if I want to have multiple languages?Sigfrid

© 2022 - 2024 — McMap. All rights reserved.