背水一战 Windows 10 (81) - 全球化
作者:webabcd
介绍
背水一战 Windows 10 之 全球化
- Demo
- 格式化数字
示例
1、演示全球化的基本应用
Localization/GlobalizationDemo.xaml
<Page
x:Class="Windows10.Localization.GlobalizationDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Localization"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="10 0 10 10"> <TextBlock Name="lblMsg" /> </StackPanel>
</Grid>
</Page>
Localization/GlobalizationDemo.xaml.cs
/*
* 演示全球化的基本应用
*
*
* 注:本地化和全球化的区别
* 1、全球化的产品应该适用于任何一个本地市场
* 2、本地化通常会有 UI 的调整,语言的翻译,甚至是针对本地开发的一些特殊的功能
* 3、一个全球化的产品做本地化时,一般只做语言翻译
*/ using System;
using Windows.Globalization;
using Windows.System.UserProfile;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation; namespace Windows10.Localization
{
public sealed partial class GlobalizationDemo : Page
{
public GlobalizationDemo()
{
this.InitializeComponent();
} protected override void OnNavigatedTo(NavigationEventArgs e)
{
// 首选语言
lblMsg.Text = "Current Languages: " + string.Join(", ", GlobalizationPreferences.Languages);
lblMsg.Text += Environment.NewLine;
// 首选日历(比如:GregorianCalendar 提供了世界上大多数国家/地区使用的标准日历系统)
lblMsg.Text += "Current Calendars: " + string.Join(", ", GlobalizationPreferences.Calendars);
lblMsg.Text += Environment.NewLine;
// 时钟显示(比如:24HourClock)
lblMsg.Text += "Current Clocks: " + string.Join(", ", GlobalizationPreferences.Clocks);
lblMsg.Text += Environment.NewLine;
// 区域(比如:CN)
lblMsg.Text += "Current HomeGeographicRegion: " + GlobalizationPreferences.HomeGeographicRegion;
lblMsg.Text += Environment.NewLine;
// 一周的第一天是周几(比如:中国是 Monday)
lblMsg.Text += "Current WeekStartsOn: " + GlobalizationPreferences.WeekStartsOn.ToString();
lblMsg.Text += Environment.NewLine;
lblMsg.Text += Environment.NewLine; // Language - 语言对象,通过指定 BCP-47 语言标记来实例化语言对象
Windows.Globalization.Language language = new Windows.Globalization.Language("zh-Hans-CN");
// 判断指定的 BCP-47 语言标记的格式是否正确
lblMsg.Text += "zh-Hans-CN IsWellFormed: " + Windows.Globalization.Language.IsWellFormed("zh-Hans-CN");
lblMsg.Text += Environment.NewLine;
// 语言的本地化名称
lblMsg.Text += "zh-Hans-CN Language DisplayName: " + language.DisplayName;
lblMsg.Text += Environment.NewLine;
// 语言本身的名称
lblMsg.Text += "zh-Hans-CN Language NativeName: " + language.NativeName;
lblMsg.Text += Environment.NewLine;
// 语言的 BCP-47 语言标记
lblMsg.Text += "zh-Hans-CN Language LanguageTag: " + language.LanguageTag;
lblMsg.Text += Environment.NewLine;
// 语言的 ISO 15924 脚本代码
lblMsg.Text += "zh-Hans-CN Language Script: " + language.Script;
lblMsg.Text += Environment.NewLine;
// 获取当前输入法编辑器 (IME) 的 BCP-47 语言标记
lblMsg.Text += "zh-Hans-CN Language CurrentInputMethodLanguageTag: " + Windows.Globalization.Language.CurrentInputMethodLanguageTag;
lblMsg.Text += Environment.NewLine;
lblMsg.Text += Environment.NewLine; // GeographicRegion - 区域对象(关于 ISO 3166-1 请参见:http://zh.wikipedia.org/zh-cn/ISO_3166-1)
GeographicRegion geographicRegion = new GeographicRegion(); // 获取当前的区域对象。
// 区域的本地化名称
lblMsg.Text += "Current Region DisplayName: " + geographicRegion.DisplayName;
lblMsg.Text += Environment.NewLine;
// 区域本身的名称
lblMsg.Text += "Current Region NativeName: " + geographicRegion.NativeName;
lblMsg.Text += Environment.NewLine;
// 该区域内使用的货币类型
lblMsg.Text += "Current Region CurrenciesInUse: " + string.Join(",", geographicRegion.CurrenciesInUse);
lblMsg.Text += Environment.NewLine;
// 该区域的 ISO 3166-1 二位字母标识
lblMsg.Text += "Current Region CodeTwoLetter: " + geographicRegion.CodeTwoLetter;
lblMsg.Text += Environment.NewLine;
// 该区域的 ISO 3166-1 三位字母标识
lblMsg.Text += "Current Region CodeThreeLetter: " + geographicRegion.CodeThreeLetter;
// 该区域的 ISO 3166-1 数字标识
lblMsg.Text += Environment.NewLine;
lblMsg.Text += "Current Region CodeThreeDigit: " + geographicRegion.CodeThreeDigit;
lblMsg.Text += Environment.NewLine;
lblMsg.Text += Environment.NewLine; // Calendar - 日历对象,默认返回当前系统的默认日历
Calendar calendarDefault = new Calendar();
// 第一个参数:将日历转换为字符串时,优先使用的语言标识列表;第二个参数:指定日历的类型;第三个参数:指定是12小时制还是24小时制
Calendar calendarHebrew = new Calendar(new[] { "zh-CN" }, CalendarIdentifiers.Hebrew, ClockIdentifiers.TwentyFourHour);
lblMsg.Text += "Gregorian Day: " + calendarDefault.DayAsString(); // 公历的日期
lblMsg.Text += Environment.NewLine;
lblMsg.Text += "Hebrew Day: " + calendarHebrew.DayAsString(); // 希伯来历的日期
// Calendar 还有很多属性和方法,不再一一介绍,需要时查 msdn
}
}
}
2、演示不同语言环境下对数字的格式化
Localization/NumberFormatting.xaml
<Page
x:Class="Windows10.Localization.NumberFormatting"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Localization"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="10 0 10 10"> <TextBlock Name="lblMsg" /> </StackPanel>
</Grid>
</Page>
Localization/NumberFormatting.xaml.cs
/*
* 演示不同语言环境下对数字的格式化
*/ using System;
using Windows.Globalization.NumberFormatting;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation; namespace Windows10.Localization
{
public sealed partial class NumberFormatting : Page
{
public NumberFormatting()
{
this.InitializeComponent();
} protected override void OnNavigatedTo(NavigationEventArgs e)
{
// 百分比格式化
PercentFormatter percentFormatter = new PercentFormatter();
// PercentFormatter percentFormatter = new PercentFormatter(new[] { "zh-Hans-CN" }, "CN");
lblMsg.Text = percentFormatter.Format(3.1415926);
lblMsg.Text += Environment.NewLine; // 千分比格式化
PermilleFormatter permilleFormatter = new PermilleFormatter();
// PermilleFormatter permilleFormatter = new PermilleFormatter(new[] { "zh-Hans-CN" }, "CN");
lblMsg.Text += permilleFormatter.Format(3.1415926);
lblMsg.Text += Environment.NewLine; // 数字格式化
DecimalFormatter decimalFormatter = new DecimalFormatter();
// DecimalFormatter decimalFormatter = new DecimalFormatter(new[] { "zh-Hans-CN" }, "CN");
lblMsg.Text += decimalFormatter.Format(3.1415926);
lblMsg.Text += Environment.NewLine; // 货币格式化
CurrencyFormatter currencyFormatter = new CurrencyFormatter("CNY");
// CurrencyFormatter currencyFormatter = new CurrencyFormatter("CNY", new[] { "zh-Hans-CN" }, "CN");
lblMsg.Text += currencyFormatter.Format(3.1415926);
}
}
}
OK
[源码下载]
背水一战 Windows 10 (81) - 全球化的更多相关文章
- 背水一战 Windows 10 (11) - 资源: CustomResource, ResourceDictionary, 加载外部的 ResourceDictionary 文件
[源码下载] 背水一战 Windows 10 (11) - 资源: CustomResource, ResourceDictionary, 加载外部的 ResourceDictionary 文件 作者 ...
- 背水一战 Windows 10 (13) - 绘图: Stroke, Brush
[源码下载] 背水一战 Windows 10 (13) - 绘图: Stroke, Brush 作者:webabcd 介绍背水一战 Windows 10 之 绘图 Stroke - 笔划 Brush ...
- 背水一战 Windows 10 (12) - 绘图: Shape, Path
[源码下载] 背水一战 Windows 10 (12) - 绘图: Shape, Path 作者:webabcd 介绍背水一战 Windows 10 之 绘图 Shape - 图形 Path - 路径 ...
- 背水一战 Windows 10 (37) - 控件(弹出类): MessageDialog, ContentDialog
[源码下载] 背水一战 Windows 10 (37) - 控件(弹出类): MessageDialog, ContentDialog 作者:webabcd 介绍背水一战 Windows 10 之 控 ...
- 背水一战 Windows 10 (36) - 控件(弹出类): ToolTip, Popup, PopupMenu
[源码下载] 背水一战 Windows 10 (36) - 控件(弹出类): ToolTip, Popup, PopupMenu 作者:webabcd 介绍背水一战 Windows 10 之 控件(弹 ...
- 背水一战 Windows 10 (35) - 控件(弹出类): FlyoutBase, Flyout, MenuFlyout
[源码下载] 背水一战 Windows 10 (35) - 控件(弹出类): FlyoutBase, Flyout, MenuFlyout 作者:webabcd 介绍背水一战 Windows 10 之 ...
- 背水一战 Windows 10 (34) - 控件(进度类): RangeBase, Slider, ProgressBar, ProgressRing
[源码下载] 背水一战 Windows 10 (34) - 控件(进度类): RangeBase, Slider, ProgressBar, ProgressRing 作者:webabcd 介绍背水一 ...
- 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch
[源码下载] 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch 作者:webabcd 介绍背水一 ...
- 背水一战 Windows 10 (32) - 控件(选择类): Selector, ComboBox
[源码下载] 背水一战 Windows 10 (32) - 控件(选择类): Selector, ComboBox 作者:webabcd 介绍背水一战 Windows 10 之 控件(选择类) Sel ...
随机推荐
- 32. linux下oracle数据库定时备份
这里以oradatabak.sh(里面的内容要根据实际修改)脚本放在/u01/11g/datapump下为例: #1.添加脚本执行权限 chmod +x /u01/11g/datapump/orada ...
- springboot2系列目录
参考:https://blog.csdn.net/cowbin2012/article/details/85254990 带源码
- i386 x86_64 armv7 arm64
arm7: Used in the oldest iOS 7-supporting devices arm7s: As used in iPhone 5 and 5C arm64: For the 6 ...
- RTTI和反射小结
Java有两种方式让我们在运行时识别对象和类的信息:1.“传统的”RTTI,假定所有的类型编译时已知:2.“反射”机制,允许在运行时发现和使用类的信息. 一.RTTI RTTI(Run-Time Ty ...
- mvc:view-controller标签使用
mvc:view-controller可以在不需要Controller处理request的情况,转向到设置的View,完成无Controller的path和view的直接映射. 1.重定向 <m ...
- 28.Hibernate-HQL查询.md
目录 1.概述 2.HQL实例 3.Criteria 查询 4.SQL本地查询 5.分页 1.概述 1)Get/load主键查询 2)对象导航查询 3)HQL查询, Hibernate Query l ...
- python中发送post请求时,报错“Unrecognized token 'xxxx': was expecting ('true', 'false' or 'null')”
解决办法: 如请求参数为 data={“user”=“aaa”,“pwd”=“123456”,sign=“00000000000000”} 需要将参数data先做处理,调用函数datas=datajs ...
- selenium之 chromedriver与chrome版本映射表(转载)
chromedriver版本 支持的Chrome版本 v2.34 v61-63 v2.33 v60-62 v2.32 v59-61 v2.31 v58-60 v2.30 v58-60 v2.29 v5 ...
- Java获取工程目录
背景:程序执行时,会涉及到去读取配置文件等操作,那就需要了解怎么获得文件路径 Java目录映射关系 说明一点:在Java代码执行时,会将编译生成的classes文件,以及配置文件等信息生成到tar ...
- APIcloud微信支付和支付宝支付(方案2,主要在后台进行)
支付宝代码 var aliPay = api.require('aliPay'); api.ajax({ url: yuming+'index.php/api/Alipay/getOrder', me ...