run your app on every windows phone 8.1 device in the world
DESCRIPTION
Presentation on the resources system of Windows Phone RT / Windows 8.TRANSCRIPT
Your app on every Windows Phone 8.1 device
in the world
14/04/2023
Who am I?
14/04/2023
Bart Lannoeye@bartlannoeye
• MADN Board Member• Microsoft MEET Member• Full-time Win8 dev
14/04/2023
• General localization best practices• Resources in WP8 vs WP8.1 RT• Multilingual App Toolkit• But we can do more !• Universal Apps
Agenda
14/04/2023
• Sentences instead of single words• The {0} could not be synchronized.
• Be aware of word order, or 1 vs multiple word parts• Provide enough space
• Hint: English + 40%• Tip: test with ‘qps-ploc’• Multiline, text wrapping, trimming
• Watch out with re-use• ‘Text’ can be noun & verb
• Use unique identifiers to access resources, as resource can change
• Stick to a localization approach• Easiest: keep translations till last• Complexity: self-translated, outsourced, automated, …
Localization best practices
14/04/2023
Windows Phone 8 (SL) Windows Phone 8.1 RT
Project setup
14/04/2023
Demo
14/04/2023
Windows Phone 8 (SL) Windows Phone 8.1 RT
.resx files don’t update ! .xlf files update on rebuildmachine generated translations
Project setup
14/04/2023
Demo
14/04/2023
Windows Phone 8 (SL)
• Generated class with classname = resources file
• MyClass with public prop to expose the generated class
• App.xaml: declare MyClass in Application.Resources
• Text="{Binding Path=MyResources.Title, Source={StaticResource LocalizedStrings}}"
• Adding a new resources file‘Inconsistent accessibility’
• Fix: use PublicResXFileCodeGenerator
Resources in XAML (1)
14/04/2023
Demo
14/04/2023
Windows Phone 8 (SL) Windows Phone 8.1 RT
• Generated class with classname = resources file
• MyClass with public prop to expose the generated class
• App.xaml: declare MyClass in Application.Resources
• Text="{Binding Path=MyResources.Title, Source={StaticResource LocalizedStrings}}"
• <TextBlock x:Uid=“MyText” />
• In resource file:MyText.Text SomeText
• Blackbox magic done for you
Resources in XAML (2)
14/04/2023
Windows Phone 8 (SL) Windows Phone 8.1 RT
• Generated class with classname = resources file
• Every resource is a static property
• string text = AppResources.SomeText
Resources in C#
14/04/2023
Demo
14/04/2023
Windows Phone 8 (SL) Windows Phone 8.1 RT
• Generated class with classname = resources file
• Every resource is a static property
• string text = AppResources.SomeText
• new ResourceLoader()or ResourceLoader .GetForCurrentView()
• string text = _loader.GetString(key);
• MyUid.Text -> MyUid/Text
• Use id in ctor / GetFCV() to access a given resource file
Resources in C#
14/04/2023
• Download MAT: https://dev.windows.com/en-us/develop/multilingual-app-toolkit
• Integrated with Visual Studio• Microsoft Language Portal integration
• Localization from actual Microsoft Products (e.g. Office)
• Machine Translator integration• Dedicated translator UI• XLIFF files: localization industry standard• Export – import files to send to 3rd party (xliff – csv)• Warning for updates, preventing accidental overwrites• Provides pseudo (qps-ploc) for testing
Multilingual App Toolkit
MAT v4 Tech Preview: support for Xamarin
14/04/2023
• Machine generated for testing purposes• Contains special characters and provides longer strings
• Some value [7B769][!!_Śóмé νàļúé_!!]
• Windows 8 / 8.1• Add qps-ploc to your language preferences and place it on top of the
list
• Windows Phone 8.1 RT• Only available in code, not a selectable system language
ApplicationLanguages.PrimaryLanguageOverride = "qps-ploc";
Note: PrimaryLanguageOverride can also be used in Win8 to change at runtime
Pseudo (qps-ploc)
14/04/2023
Demo
14/04/2023
• Use resource system for most dependency properties• Use resource system for different scaling factors
• Resource.scale-140.resw• Image.scale-140.png
• Application name & other Appxmanifest properties• ms-resource:AppName
• Offload resources to a separate assembly: specify path as Id• new
ResourceLoader("App1.SomeResources/Resources").GetString("MyString");
• <TextBlock x:Uid="/App1.SomeResources/Resources/SomeControl" />
But we can do more !
14/04/2023
Demo
14/04/2023
• ‘Visual layer to increase tooling support over linked files’• If:
• Resources work on Windows 8 / 8.1• Resources work on Windows Phone 8.1 RT• Universal Apps is ‘just linked files’
• Then the resources system works in Universal Apps as well (*)
• (*) Remarks:• MAT only on Windows / Windows Phone project, not on Shared• Use export – import to prevent translating twice• Want .xliff files on 1 place? Use a PCL instead
Next step: Universal Apps
14/04/2023
Demo
14/04/2023
Keep in touch
Bart Lannoeye@bartlannoeye
14/04/2023
www.madn.be@MADNbe