Localization in Xamarin DateTime Range Navigator
18 Apr 20231 minute to read
You can localize SfDateTimeRangeNavigator
in all the platforms by adding a .resx file in a .NET Standard project alone. The following steps describe how to localize SfDateTimeRangeNavigator in a project.
NOTE
Here, the resources have been already created for some cultures and shared them on
Syncfusion GitHub
for your convenience.
-
Add a new folder in the .NET Standard project named Resources.
-
Add resource files for the languages you wish to support and set their Build Action to EmbeddedResource. The name of the resource file should be $name of the Syncfusion component$+$language code$+.resx. For example, if you add a resource file for the French culture, add the Syncfusion.SfChart.XForms.fr-FR.resx file to Resources folder as illustrated in the following screenshot.
- Provide the French values for each key in the respective .resx files. Here, “Quarter” and “Week” are the keys, and “Trimestre” and “La semaine” are their respective French values.
<data name="Quarter" xml:space="preserve">
<value>Trimestre</value>
</data>
<data name="Week" xml:space="preserve">
<value>La semaine</value>
</data>
- Set resource manager to ‘RangeNavigatorResourceManager.Manager’ to get the resource manager from users as demonstrated in the following code sample. For more details, please refer
Localization
.
RangeNavigatorResourceManager.Manager = new ResourceManager("GettingStarted.Resources.Syncfusion.SfChart.XForms", Application.Current.GetType().Assembly);
Localize at application level
You can also localize the text at application-level regardless of the language selected on the device. The following platform-specific codes are needed to localize the text at application-level. Use the DependencyServices
to set this from .NET Standard project.
//For Android and iOS,
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
//For UWP,
CultureInfo.CurrentUICulture = new CultureInfo("fr-FR");