2
votes

I have an issue regarding the Xamarin Forms Picker control (https://developer.xamarin.com/api/type/Xamarin.Forms.Picker/). It seems that the "Done" button, which is rendered on the top right part of the picker on iOS, cannot be translated.

To further illustrate the issue, I have attached a screenshot. You can also see that the language of the device itself does not have impact on the "Done" label. You can see this because the device is set to Dutch, which can be verified by looking at the "Geen simkaart" text in the top left of the image.

Am I missing something in the API, or would it be possible to translate the text using a Custom Renderer?

The screenshot: https://s15.postimg.org/hhbbd2w9n/IMG_0005_masked.png

2

2 Answers

1
votes

The "Done" button is a UIBarButtonSystemItem.Done style, which means it should translate automatically when you switch the language on iOS, given that you have provided the translation strings in Localizable.strings as per the Xamarin Documentation: https://developer.xamarin.com/guides/ios/advanced_topics/localization_and_internationalization/#platform

So in your Info.Plist you would add your additional language:

<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleLocalizations</key>
<array>
  <string>dk</string>
</array>

Then for the base language you need to add a Base.lproj directory in in Resources. Then for each other supported language you add a <language>.lproj folder, in this case dk.lproj.

Inside each of these folders new file called Localizable.strings. Then you add keys for the languages in the format:

"key"="localized-value";

The base will be the language code defined in CFBundleDevelopmentRegion as you added in the Info.Plist.

I would probably just do this for the System buttons such as Done, Add, Delete etc. for other buttons and strings I would use a Resx file or similar, which can be used shared between the platforms you support.

0
votes

The button text "Done" is already translated by the system:

https://developer.apple.com/documentation/uikit/uibarbuttonsystemitem/uibarbuttonsystemitemdone

To make the translation work, all you need to do is to set the supported languages in the info.plist file. No actual translations need to be provided.

<key>CFBundleLocalizations</key>
<array>
  <string>en</string>
  <string>ro</string>
</array>