Bug 40141 - Localization sample cannot work in XAML codes
Summary: Localization sample cannot work in XAML codes
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.1.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-04-06 06:04 UTC by Jesse Jiang
Modified: 2016-04-11 13:57 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Translate not work on XAML (30.32 KB, image/png)
2016-04-06 06:04 UTC, Jesse Jiang

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jesse Jiang 2016-04-06 06:04:02 UTC
Created attachment 15621 [details]
Translate not work on XAML


Run this sample,
 in Chinese language environment, you will find that the C# tabbed page works well, but the XAML page cannot translate to Chinese.

Quick Fix:
In TranslateExtension file change ProvideValue function to this
        public object ProvideValue(IServiceProvider serviceProvider)
            if (Text == null)
                return "";

            ResourceManager temp = new ResourceManager(ResourceId
                , typeof(TranslateExtension).GetTypeInfo().Assembly);

            return temp.GetString(Text);

Do not pass the ci to GetString

Is this Xamarin.Forms bug or Sample's bug?
Comment 1 Rui Marinho 2016-04-07 15:56:59 UTC
It's working ok for me with the French Language, is this something that only happens in chinese?

Doesn't seem like a Xamarin Forms bug
Comment 2 Jesse Jiang 2016-04-07 23:22:26 UTC
I did more testing, I found that simplified Chinese can raise this issue and it only happens in iOS.

I found that in Android the Localize return culture as "zh-CN". That works for XAML

But iOS return "zh", that not work.

I have also test traditional Chinese, it works well on iOS.

So I think I need to push a request for the demo project

Comment 3 Rui Marinho 2016-04-11 13:57:58 UTC
Yes i think is better to create a issue on Github please.