Run your app on every Windows Phone 8.1 device in the world

23
Your app on every Windows Phone 8.1 device in the world 13/05/2022

description

Presentation on the resources system of Windows Phone RT / Windows 8.

Transcript of Run your app on every Windows Phone 8.1 device in the world

Page 1: Run your app on every Windows Phone 8.1 device in the world

Your app on every Windows Phone 8.1 device

in the world

14/04/2023

Page 2: Run your app on every Windows Phone 8.1 device in the world

Who am I?

14/04/2023

Bart Lannoeye@bartlannoeye

• MADN Board Member• Microsoft MEET Member• Full-time Win8 dev

Page 3: Run your app on every Windows Phone 8.1 device in the world

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

Page 4: Run your app on every Windows Phone 8.1 device in the world

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

Page 5: Run your app on every Windows Phone 8.1 device in the world

14/04/2023

Windows Phone 8 (SL) Windows Phone 8.1 RT

Project setup

Page 6: Run your app on every Windows Phone 8.1 device in the world

14/04/2023

Demo

Page 7: Run your app on every Windows Phone 8.1 device in the world

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

Page 8: Run your app on every Windows Phone 8.1 device in the world

14/04/2023

Demo

Page 9: Run your app on every Windows Phone 8.1 device in the world

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)

Page 10: Run your app on every Windows Phone 8.1 device in the world

14/04/2023

Demo

Page 11: Run your app on every Windows Phone 8.1 device in the world

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)

Page 12: Run your app on every Windows Phone 8.1 device in the world

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#

Page 13: Run your app on every Windows Phone 8.1 device in the world

14/04/2023

Demo

Page 14: Run your app on every Windows Phone 8.1 device in the world

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#

Page 15: Run your app on every Windows Phone 8.1 device in the world

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

Page 16: Run your app on every Windows Phone 8.1 device in the world

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)

Page 17: Run your app on every Windows Phone 8.1 device in the world

14/04/2023

Demo

Page 18: Run your app on every Windows Phone 8.1 device in the world

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 !

Page 19: Run your app on every Windows Phone 8.1 device in the world

14/04/2023

Demo

Page 20: Run your app on every Windows Phone 8.1 device in the world

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

Page 21: Run your app on every Windows Phone 8.1 device in the world

14/04/2023

Demo

Page 22: Run your app on every Windows Phone 8.1 device in the world

14/04/2023

Page 23: Run your app on every Windows Phone 8.1 device in the world

Keep in touch

Bart Lannoeye@bartlannoeye

14/04/2023

www.madn.be@MADNbe