背水一战 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 ...
随机推荐
- JEECG 上传插件升级-代码生成器
前言: 现有的uploadify上传是基于swf的,随着H5的普及,flash即将退出历史舞台,JEECG本着与时俱进的原则,将全面升级JEECG系统中的上传功能,采用新式上传插件plupload,此 ...
- JRebel 代理激活
1.生成GUID https://www.guidgen.com/ 例:04cfff79-8f45-481c-a858-a5b9590422e7 2.License Server 例: http: ...
- http://www.36dsj.com/archives/46131
https://docs.growingio.com/Developer%20Document.html https://youdata.163.com/dash/39706/editor?pid=7 ...
- SVN中英文菜单对照
TortoiseSVN英文版菜单中文翻译01.SVN Checkout(SVN取出) 点击SVN Checkout,弹出检出提示框,在URL of repository输入框中输入服务器仓库地址,在C ...
- Pandas基础知识(二)
Pandas的索引对象 index的对象是不可以修改的如执行index[1] = 'f',会报错"Index does not support mutable operations" ...
- 使用JavaMail发送邮件-从FTP读取图片并添加到邮件正文发送
业务分析: 最近工作需要,需要从FTP读取图片内容,添加到邮件正文发送.发送邮件正文,添加附件采用Spring的MimeMessageHelper对象来完成,添加图片也将采用MimeMessageHe ...
- easyui datagrid自定义按钮列,即最后面的操作列
在很多时候我们要在表格的最后添加一列操作列,easyUI貌似没有提供种功能,不过没关系,我们可以自定义来实现首先是HTML部分 <table id="tt" class=&q ...
- CO-产地证--需要的国家以及操作流程。
需要产地证的国家一般是与中国有合作的亚非拉国家,比如: 巴基斯坦.智利.以色列.韩国.土耳其.越南.澳大利亚. 流程: 1.在海关官网上填报信息. 2.提交,客户在他国家的官网上确认. 3.确认无误后 ...
- git tag的用法
我们常常在代码封板时,使用git 创建一个tag ,这样一个不可修改的历史代码版本就像被我们封存起来一样,不论是运维发布拉取,或者以后的代码版本管理,都是十分方便的 git的tag功能 git 下打标 ...
- [leetcode]236. Lowest Common Ancestor of a Binary Tree二叉树最近公共祖先
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. Accordi ...