Customize Calendar Winrt Xaml Toolkit - windows

I'm developing an Universal App for Win8.1, i've added the Winrt Xaml Toolkit dll but when i use Calendar control the strings of months appear only in English.
Is there any way to change them? I'm going crazy :D
PS: I've downloaded the source code of dll but there is no track of these strings

If you look at the DateTimeHelper class, you can see the method GetCurrentDateFormat which uses the en-US format. This method is used in many places for the Calendar and CalendarItem controls from the toolkit.
You can try to import the project from the site instead of using the NuGet package and then change this method to use your device locale. You can maybe change it to something like this:
public static DateTimeFormatInfo GetCurrentDateFormat()
{
return CultureInfo.CurrentCulture.DateTimeFormat;
}
I haven't tested this code so this is just a hint where you should look for your solution.

Related

How to add Windows Phone project with resx localization to Xamarin PCL solution?

I have a working PCL project for iOS and I'm trying to create the Windows Phone 8.1 version.
I'm following this tutorial: https://developer.xamarin.com/guides/xamarin-forms/advanced/localization/
And checking the app at: https://github.com/xamarin/xamarin-forms-samples/tree/master/UsingResxLocalization
But it is too deprecated. Even the git project is different from the tutorial, and none of them works.
The ILocalize interface for Windows should look like:
[assembly: Dependency(typeof(UsingResxLocalization.WinPhone.Localize))]
namespace UsingResxLocalization.WinPhone
{
public class Localize : UsingResxLocalization.ILocalize
{
public System.Globalization.CultureInfo GetCurrentCultureInfo ()
{
return System.Threading.Thread.CurrentThread.CurrentUICulture;
}
}
}
But System.Threading.Thread.CurrentThread.CurrentUICulture simply doesn't exist. I found out that I can use Windows.System.UserProfile.GlobalizationPreferences.Languages[0].ToString() instead.
It works for the localized language resources but the default Resource is not working either for the default language "en" or any other non localized language like "ru". I get another error:
In the TranslateExtention class ProvideValue() method I get:
Key 'Start' was not found in resources 'AppNameSpace.AppResources' for
culture 'en'
Being "Start" the first key it tries to get from the resource. It happens for all the other keys on the project.
AppNameSpace.AppResources would be the right file, and "en" is the region I set, so it should work. But it's not.
I'm also getting the following warning when compiling:
The assembly "MyApp.dll"
does not have a NeutralResourcesLanguageAttribute on it. To be used in
an app package, portable libraries must define a
NeutralResourcesLanguageAttribute on their main assembly (ie, the one
containing code, not a satellite assembly). 4>C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(1216,5):
warning APPX2002: Cannot find the neutral resource language for the
resources for portable library 'MyApp'. Verify that
the portable library defines a NeutralResourcesLanguageAttribute. The
build is continuing assuming the project's default culture of 'en-US'
correctly identifies the portable library's neutral resources.
4>MakePRI : warning 0xdef00522: Resources found for language(s) 'de,
es, fr, pt' but no resources found for default language(s): 'en-US'.
Change the default language or qualify resources with the default
language. http://go.microsoft.com/fwlink/?LinkId=231899
But I have no idea how to fix it.
On the tutorial it also says:
Windows Phone projects must be properly configured for localized text
to be displayed. Supported languages must be selected in the Project
Options and the WMAppManifest.xml files. If these settings are not
updated the localized RESX resources will not be loaded.
Fine, but those options doesn't exist anymore. At least where they should be. I even found a Package.appxmanifest file in my project, but it doesn't have those regional options.
So, I need help with an updated way to do it.
Thanks
So I found out that when you add a Windows Phone project to a solution with no Windows Phone projects, it doesn't add everything it needs.
Also the tutorials don't show everything that is necessary (no big news there).
All my project was missing was [assembly: NeutralResourcesLanguage("en-US")] in my PCL AssemblyInfo.cs file.
The RESX tutorial also says that you should use:
if (Device.OS == TargetPlatform.iOS || Device.OS == TargetPlatform.Android)
{
ci = DependencyService.Get<ILocalize>().GetCurrentCultureInfo();
}
In the TranslateExtention.cs file because Windows Phones don't need it. Well, that's false. At least for the emulator to get the right language, it needs to use the DependencyService and get the CultureInfo this way:
System.Globalization.CultureInfo ci = null;
ci = new System.Globalization.CultureInfo(Windows.System.UserProfile.GlobalizationPreferences.Languages[0].ToString());
return ci;

Accessing resources XML from another library project in Xamarin.Android

I am trying to create a Xamarin.Android Component to send to the Xamarin Component Store, and I need to bundle my Colors.xml with it, so it is accessible to everyone using my component. I am setting the build action for the Colors.xml tp "AndroidResource".
So I created an Android sample application, when I add a reference to my library project's dll, I am able to use the colors defined, my project compiles and it runs, but I get no intellisense on Xamarin Studio. So that would be a bad thing for anyone using my library, as they would not be able to even see that the colors are available to use. You can see in this picture the colors defined are not available in the suggestions box.
If I add the Colors.xml directly into my project, I get Intellisense support, like this:
Is there a way to achieve the same result above when adding just the dll reference? Did I do something wrong or Xamarin.Android/Xamarin Studio doesn't support this kind of scenario?
EDIT: To be clear, I know this is a problem with Intellisense not being able to pick up the values, but is there anything I can do to make it work?

CultureTypes in WP7

Hi I want to access the CultureTypes in Windows Phone. In Silverlight/WPF i can use like this,
CultureInfo[] specificCultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
But In Windows Phone it showing an error as "UnKnownEntity" in CultureTypes
Also I want to get the Id of the CurrentCulture. In Silverlight/WPF, i can use like
Thread.CurrentThread.CurrentCulture.LCID
But in Windows Phone it showing an error as "NotFound" in LCID
Could you please anyone can help me?
In Silverlight/WPF i can use like this
You can in WPF, but not in Silverlight. Look at the Silverlight version of the documentation for CultureInfo - there's no GetCultures method. I don't see any way of getting all cultures - just the current culture, current UI culture, and invariant culture. (You can create your own instances by calling the constructor, of course.)
EDIT: You've run into exactly the same problem when trying to get the LCID. You can't just assume everthing from the desktop framework will be available in Silverlight. You need to look at the Silverlight-specific documentation to see what's available (and then check that it's available on Windows Phone 7, too).
You could use T4 generator to generate missing information. I have done this for similiar problem and works great.

How to Integrate non supported fonts in WP7

I am creating a English to Mangolean Dictionary app; So i need to display mangolean word corresponding to my english word; i read from a blog that wp7 only supports limited language set. So how can i over come my issue. Please help me to solve this issue.
There's a tutorial on embedding fonts in Silverlight here: http://paulyanez.com/interactive/index.php/2009/12/embedding-fonts-in-silverlight/ The implementation for Windows Phone is exactly the same. The tutorial uses Expression Blend (which is part of the developer tools download and also free for Windows Phone), which is the simplest, quickest, and easiest way to embed fonts for Silverlight.
Apart from the supported Fonts you can add your on fonts to you project. For example create a folder named Fonts in you project and add you *.TTF files(Font Files). By referring this font files you can resolve your issues.

Localizing Windows Phone 7 App

I'm having a little trouble getting localized resources files to work on Windows Phone 7. Here's what I'm doing:
Create a resource file, say "Strings.resx" (Build Action: Compile)
Create a key, say "TestKey" with a default value of empty string
Add a English resource file in the same folder with a value of "some English string": Strings.en-us.resx (Build Action: Embedded Resource)
Add a Japanese resource file in the same folder with a value of "some Japanese string": Strings.ja-jp.resx (Build Action: Embedded Resource)
In my PC Silverlight, WPF Apps that works fine when I change the Thread.CurrentThread.CurrentCulture. But in the phone I always seem to be getting the value that's in the Strings.resx file - an empty string.
I have tried using the designer generated code and wiring up the resource manager by hand and it does not seem to matter. Here's my code:
Type t = typeof(Strings);
_resourceManager = new ResourceManager(
t.Namespace + "." + t.Name,
t.Assembly);
_resourceManager.GetString("TestKey");
Tell me localized resources are supported on the phone... ;> What am I doing wrong? Thanks!
Update: Thanks Olivier for forwarding the link. I saw that as well but missed an important step. I didn't add the "SupportedCultures" node to my csproj. Made all the difference - hoping someone else doesn't loose two hours trying to figure this out like I did.
<SupportedCultures>de-DE;es-ES;</SupportedCultures>
Of course, localized resources are supported on the phone:
How to: Build a Localized Application for Windows Phone
I wrote a blog post that provides links to a bunch of Globalization / Localization guides for WP7. There is a Windows Phone 7 in 7 Training video that helped me understand the basics. After that it was simply a matter of learning how to do databinding:
The MSDN article shows you how to
setup the files and create the
LocalizedStrings class, but they then
assume that you know how to use that
class for data binding. Visual Studio
2010 and Silverlight handle data
binding differently than Winforms, and
it gets even more confusing since XAML
also has it’s own definition of
Resources that are different then the
.NET resources we just created.
Silverlight also uses the term
Resource to refer to files that use
the the Build Action of "Content”, as
these files get wrapped up into the
.XAP file similar to how files with
Build Action of "Resource” get
embedded into the .Dll assembly (ex:
loading an image from content or
resource files). I found that instead
of using the Text="{Binding
Path=resourceFile.resourceName,
Source={StaticResource
Localizedresources }}" XAML syntax it
was easier to use the following steps:
Open your primary XAML page (usually MainPage.xaml) in the Visual
Studio designer
Open the properties for the PhoneApplicationPage and set the
DataContext to be
Application.Resources –>
LocalizedStrings. NOTE: if you already
are using a DataContext object, then
you should integrate the
LocalizedStrings class into that
object so that it has localization
support.
Once the Page’s DataContext has been set you can change the data
binding for any control on the page by
simply selecting the property (ex:
text, checked, etc), selecting “Apply
Data Binding…”, and setting the Path
to Localizedresources.BtnText or
whatever the name of the desired
resource value is.

Resources