Supported Cultures Box not available in manifest - visual-studio-2013

This msdn link says that to add more language to your windows phone app, you need to make changes in the supported culture box in the properties page, but I can't find such box in the properties page as well as manifest page.
I tried searching all the tabs and I have uploaded the screenshots of properties page as well as manifest, but I'm not able to find the required box.
I have developed an application and updated on the store but only English (US) is the supported language and I'm not able to localize the app.
I'm not able to add screenshots as it requires more that 10 reputation.

Adding resource files
You do not specify what languages you support in the project properties any more. You only specify the default language in the app manifest.
You have to manually add one .resw file for each language you support. The files must all be named Resources.resw and must be placed in a sub-folder, named after the language, under a “Strings” folder in your project.
Accessing resources from xaml
You access the resources by setting the x:Uid property of a control to a unique name. Unfortunately the x:Uid property is not recognized by the properties window, neither in VisualStudio nor in Blend, so you must hand code it directly in the xaml file.
Example:
<TextBlock x:Uid="MyTextBlock" /> <Button x:Uid="MyButton" />
<TextBlock x:Uid="MyTextBlock" />
You must then add a resource with the uid-name with dot-notation, that is, after the dot you write the name of the property of the control in which you want the text.
Reference : http://www.jayway.com/2014/04/22/windows-phone-8-1-for-developers-localizing-apps/

Related

How to display Bootstrap icons in Xamarin?

I'm new to Xamarin development, but try to be exact.
Using Visual Studio 2022, with Xamarin version 17.0.0.182 (as displayed in VS About).
Found this great article on how to use Bootstrap icons, but it seems to be out of date. When I followed the steps and provided hex codes for the characters, I didn't get the expected glyiphs.
I found that
new Xamarin needs new methods,
new Bootstrap fonts need new ways.
Here they are.
1.) Get the font from the Bootstrap github repo at https://github.com/twbs/icons
Go to releases (https://github.com/twbs/icons/releases), choose latest, scroll down to Assets, download the bootstrap-icons-x.x.x.xip file.
Unzip it, and find fonts/bootstrap-icons.woff.
Not something you can use in Xamarin right away :-(
2.) Convert the woff file to ttf
I googled for a converter and used https://cloudconvert.com/woff-to-ttf
Now you have the ttf you need :-)
3.) Now follow the current Xamarin method of adding a font to your app.
The process is described here: https://devblogs.microsoft.com/xamarin/embedded-fonts-xamarin-forms/
In short:
add the ttf file to the shared Xamarin project, Embedded Resources / Fonts
change file properties / Build Action to "Embedded resource"
register the font by adding a line to the end of Assemblyinfo.cs:
[assembly: ExportFont("bootstrap-icons.ttf", Alias = "Bootstrap")]
4.) Use it in xaml like
<Label FontFamily="Bootstrap" Text=""/>
to display a magnifying glass.
You may also define a Label style, but I'll skip that for now.
4/b.) To use it in xaml via binding
Oh, if things were easy...
When using a binding to display a glyph, there's one more hoop to jump, thanks to these guys for the solution: Using data binding, how do I bind text which contains emojis to a label and have it display correctly?
So, in xaml:
<!-- set BindingContext to MyViewModel -->
<Label FontFamily="Bootstrap" Text="{Binding StateIconName}" />
in your MyViewModel:
public string StateIconName
{
get => WebUtility.HtmlDecode("");
}
5.) To browse available glyphs (icons)
Open the overview page: https://icons.getbootstrap.com/
6.) To find the unicode character code, also referred to as "Unicode HTML Entity"
Check the name of the icon above in step 5.
Open the Bootstrap-icons.css file from Github: https://github.com/twbs/icons/blob/main/font/bootstrap-icons.css
Search for the name of the glyph to find the character code, something like:
.bi-zoom-in::before { content: "\f62c"; }
Use this code in xaml like

Localizing attached properties in XAML/WinRT

I'm attempting to localize my WinRT app. I don't need anything too fancy, so I've been using x:Uid on XAML elements in conjunction with resource files that have properties such as "PageTitleTextBox.Text" set. This method was working great until I ran into an issue with attached properties.
I've defined a few app bar buttons using similar markup to what I've seen in other examples:
<Button x:Name="AddFolderButton" Click="AddFolderButton_Tapped" x:Uid="FoldersPageAppBarAddFolderButton" AutomationProperties.Name="Test" Style="{StaticResource AppBarButtonStyle}">
<Button.Content></Button.Content>
</Button >
In this case, I'd like to localize AddFolderButton's label, currently defined by AutomationProperties.Name. I tried setting a key in my resource file to FoldersPageAppBarAddFolderButton.AutomationProperties.Name, but this fails on runtime.
Is it possible to localize this label using XAML, or do I need to do this programatically in the code-behind file?
You need to handle attached properties a bit differently, i.e. their namespace must be included in the reource key like this:
FoldersPageAppBarAddFolderButton.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name
You can read more about it here.

Wp7 background image not showing up when i debug

I'm new to WP7 programming but have XP with other platforms, I am just running through all the basics so I can get to know the language but I have hit a roadblock I've entered a source for my background image:
<Grid x:Name="LayoutRoot">
<Grid.Background>
<ImageBrush ImageSource="C:/users/hypernova/pictures/Background1.jpg">
</ImageBrush>
</Grid.Background>
</Grid>
And the image shows up as a background in the design tab that is next to the XAML but when I debug and the emulator starts its just a black screen no background image, what have I missed? I have tried other ways of setting a background like:
<Grid x:Name="LayoutRoot">
<Canvas>
<Canvas.Background>
<ImageBrush ImageSource="C:/users/hypernova/pictures/Background1.jpg">
</ImageBrush>
</Canvas.Background>
</Canvas>
</Grid>
but the same thing happens I've tried a few other ways also but again nothing, I'm sure I've missed something I should have caught.
The path
C:/users/hypernova/pictures/Background1.jpg
exists on your dev machine, not on any Windows Phone 7+ device.
Remember, users will be downloading your app from the store, then running it on their phones. How would they possibly access your hard drive and get that image?
Unfortunately, since the design surface allows you to do this, it can of course be confusing to a new developer.
What you should do is add your image to your project as a Resource, then reference the resource via a pack URI (don't click on that link unless you want to scare yourself silly).
To add it as a resource, simply add the image to the root of your WP7 project, right click on it, select Properties, and then change the build action to Resource (not Embedded Resource, mind you).
Next, you have to construct a pack URI for this resource. This is ... not easy. You can use the tools in Visual Studio to do this, by editing the properties of your ImageBrush in the designer. This is the simplest, and recommended, route. All you have to do is edit the ImageSource of your ImageBrush in the Properties tool window, and select the image from the list of available images in the solution.
The other way is to manually construct the pack URI. For example, you could take the following
/[project assembly name];component/Background1.jpg
replace [project assembly name] with the name of your assembly (no extensions), and use it as your ImageSource value. You can find the correct project assembly name by looking at the Assembly Name under the Application section of the project properties.
<ImageBrush ImageSource="/MyWp7Application;component/Background1.jpg"/>
Note, depending on how your project folder structure is constructed, this URI may be different. Constructing the correct URI outside of the tools provided is a task deserving of another question.

Localizing for sub-cultures on WP7 not getting picked up

I am trying to localize my wp7 application and I need to have different strings for de-DE and de-AT because there are some language differences between those two cultures even though the basic settings are the same.
I did the following to achieve this:
Created an AppResources.resx file for the default English text
Created an AppResources.de-DE.resx file for the German text
Created an AppResources.de-AT.resx file for the German text for Austrian sub culture
in the Assembly Information... in the project properties I set English as my Neutral Language
I closed the solution, opened up my project.csproj file and changed the <SupportedCultures/> to the following: <SupportedCultures>de-AT;de-DE</SupportedCultures>
I added a new Class LocalizedStrings, registered it in Application.Resources in App.xaml and changed the output string accordingly.
Both the Emulator as the handset are set to Austrian Locale, System.Globalization.CultureInfo.CurrentCulture.ToString(); returns de-AT, but regardless of that the texts defined in AppResources.de-DE.resx are used and not the ones defined in the file for the Austrian culture.
Any idea how I might solve this issue?
You should check the CultureInfo.CurrentUICulture, not the CurrentCulture!
That is the property that controls what resources get loaded for interface!
The value of CurrentUICulture should match the one selected in the phone/emulator Settings -> Region+Language -> Display Language.
Ideally, you can always override the system imposed CurrentUICulture by setting a different CultureInfo on Thread.CurrentUICulture.

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