'Localization and Globalization'에 해당되는 글 3건
- 2018.01.01
- 2018.01.01
- 2017.12.30
Copyright
이 모든 내용은 Pluralsight에 Jeremy Clark가 올린 'Localization and Globalization in .NET'라는 강의의 마지막 챕터를 듣고 정리한 것입니다(https://app.pluralsight.com/library/courses/intro-to-localization-globalization-dotnet/table-of-contents).
Summary (생략)
Course Summary (생략)
Resource
Resgen.exe : Converts between different resource file types (.txt, .resx, .resources, .resw) (link)
LocBaml : Another way to localize WPF applications (link)
Globalization, Internationalization, and Localization in ASP.NET MVC 3, JavaScript and jQuery (link)
출처
이 모든 내용은 Pluralsight에 Jeremy Clark가 올린 'Localization and Globalization in .NET'라는 강의의 마지막 챕터를 듣고 정리한 것입니다(https://app.pluralsight.com/library/courses/intro-to-localization-globalization-dotnet/table-of-contents). 제가 정리한 것보다 더 많은 내용과 Demo를 포함하고 있으며 최종 Summary는 생략하겠습니다. Microsoft 지원을 통해 한달간 무료로 Pluralsight의 강의를 들으실 수도 있습니다.
(Localization and Globalization in .NET) Considerations (0) | 2018.01.01 |
---|---|
(Localization and Globalization in .Net) Fundamentals (0) | 2017.12.30 |
.Net ecosystem (0) | 2017.12.03 |
Copyright
이 모든 내용은 Pluralsight에 Jeremy Clark가 올린 'Localization and Globalization in .NET'라는 강의의 네번째 챕터를 듣고 정리한 것입니다(https://app.pluralsight.com/library/courses/intro-to-localization-globalization-dotnet/table-of-contents).
Outline
Naming Resource Strings
Danger of culture-specific Image
Translation Considerations
Screen Layout
Exception Messags
Code Analysis Globalization Rule
Resource Naming Recommendation
Name the resources based on their purpose
Page/View-Level Resources
Naming based on purpose
Grouping_Purpose or Grouping_Grouping_Purpose
Assembly-Level Resources
Naming based on purpose
Module_Grouping_Purpose
e.g., MainWindow_Customer_Rating
The Danger of culture-specific Images
The Danger of Flags for Language
If possible, use images that do not rely on culture-specific references
e.g., A US mailbox may not be recognized in another culture, use a letter or postage stamp image instead
If possible, do not include words as part of images
If it is not possible to avoid culture-specific references, then load localized images into the .resx file along with localized strings
Translation Considerations
Machine Translation (like google translator)
Not good enough to go straight into production
But can help with screen layout during development
Human Translation
Prefer native speakers of the target language
Still not perfect - Locker Issue
Best Bet
A human translator who understands the business purpose of the application
Provide the human translator with the business context and let him determine what is best
(Screen shots and Descriptions of a program... etc)
Screen Layout Concerns
Different languages take up different amounts of space.
German words are usually long
Japanese words are usually short
Some languages read right-to-left
Use flow layouts for greatest flexibility
In XAML : use grids and stack panels to hold our controls
Avoid fixed positions and sizes
Favor auto-sizing controls and grids
Windows Forms : TableLayoutPanel, WinRes Tool
WPF, UWP : Grids and StackPanels, Grid - Auto and Star
Exception Messages
To Localize...
The message is displayed to the user
The user can act on the message
To not Localize...
The message is not displayed to the user
The message is logged for support staff
# Exception Thrower
private void ExceptionThrower(Type exceptionType)
{
var currentCulture = Thread.CurrentThread.CurrentUICulutre;
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
try
{
Exception ex;
ex = Activator.CreateInstance(exceptionType) as Exception;
throw ex;
}
finally
{
Thread.CurrentThread.CurrentUICulture = currentCulture;
}
}
Code Analysis Globalization Rule
FXCop is a downloadable tool that analyzes our code and provides suggestions based on a set of rules
This has been incorporated into the Code Analysis tool that is available in some of the VS versions
We're able to choose a rule set that we want to use for analysis in our project.
This is available in the Solution properties.
One of the rule sets is Microsoft Globalization Rules (specifically checks for items that may affect localization and globalization)
The Globalization Rule Set consists of 11 Rules (check the rules for detail)
e.g., 1.Set Microsoft Globalization Rules in Solution properties -> Code Analysis Settings -> Change Rule Set
2. Analyze menu -> Run Code Analysis On Solution
3. Fix the error messages
Warning : Code Analysis do not work at XAML markup
Summary (생략)
출처
이 모든 내용은 Pluralsight에 Jeremy Clark가 올린 'Localization and Globalization in .NET'라는 강의의 네번째 챕터를 듣고 정리한 것입니다(https://app.pluralsight.com/library/courses/intro-to-localization-globalization-dotnet/table-of-contents). 제가 정리한 것보다 더 많은 내용과 Demo를 포함하고 있으며 최종 Summary는 생략하겠습니다. Microsoft 지원을 통해 한달간 무료로 Pluralsight의 강의를 들으실 수도 있습니다.
(Localization and Globalization in .NET) Globalization (0) | 2018.01.01 |
---|---|
(Localization and Globalization in .Net) Fundamentals (0) | 2017.12.30 |
.Net ecosystem (0) | 2017.12.03 |
Copyright
이 모든 내용은 Pluralsight에 Jeremy Clark가 올린 'Localization and Globalization in .NET'라는 강의의 첫번째 챕터를 듣고 정리한 것입니다(https://app.pluralsight.com/library/courses/intro-to-localization-globalization-dotnet/table-of-contents).
Content
1. Fundamentals
Definitions
Localization
The process of adapting an application so that its resources can be replaced at runtime.
(Language, region, culture etc... => strings, images)
Globalization
The process of engineering an application so that it does not have cultural preconceptions.
(DateTime, number, currency, calendars formats etc... => cultural formatting and other things)
Internationalization
The process of localizing and globalizing an application
.NET Localization Support
CultureInfo object (specify a language or both language and culture) (link)
Use this in conjunction with Resource files to create localized strings and images for application
These get compiled into satellite assemblies, and are used based on the culture values of the current thread.
CultureInfo(string name)
virtual string Name { get; }
virtual DateTimeFormatInfo DateTimeFormat { get; set; }
virtual NumberFormatInfo NumberFormat { get; set; }
virtual Calendar Calendar { get; }
virtual Calendar[] OptionalCalendars { get; }
virtual bool IsNeutralCulture { get; }
A neutral culture is one that specifies a language, but not a country or region.
e.g., en is neutral culture, en-US is specific culture
Neutral Cultures still have date time and number formatting information
Formatting and other values are set based on the defaults for the language
e.g., The default values for the English language are based on US English. Warning
static CultureInfo InvariantCulture { get; }
We can create an invariant culture by using an empty string for the CultureInfo constructor.
e.g., var invariantCulture = new CultureInfo("");
Or, can use the static InvariantCulture property on the CoultureInfo object
e.g., var invariantCulture2 = CultureInfo.InvariantCulture;
Invariant Culture is designed for things that should not change with culture
It can be use to persist data in culture-independent format
Invariant Culture is associated with the English language but no culture or region
#so There is neutral culture, specific culture, and invariant culture
static CultureInfo CurrentCulture { get; set; }
Gets or sets the System.Globalization.CultureInfo object that represents the culture used by the current thread
static CultureInfo CurrentUICulture { get; set; }
Gets or sets the CultureInfo object that represents the current user interface culture used by the Resource Manager to look up culture-specific resources at run time
Culture List in MSDN
Resource
Any non-executable data that is logically deployed with an app, including strings, images, and persisted objects.
.NET offers several ways to handle resources.
We will use resx file, or resw file(for UWP)
This gives us a centralized place to put localized strings.
.resx or .resw file contains value withh Name(key), value whill be displayed in our application.
Create culture-specific resource files and set Name-Value pair
Using Resource
WPF XAML
<TextBlock Text="{x:Static resx:Resources.Customer_Customer}" ..../>
ASP.NET MVC Markup
<td>@MVCOrderTaker.Resources.Home.Index.Customer_Customer</td>
C# Code
ProductName = Properties.Resources.Product_UniversalTranslator;
Satellite Assemblies
The compiler generates satellite assemblies.
hub-and-spoke model (image)
Thread and Culture
class Tread : ...
public static Tread CurrentThread { get; }
public CultureInfo CurrentCulture { get; set; } //Determines globalization, formats(data, number, currency), sorting calendars etc
public CultureInfo CurrentUICulture { get; set; }
//Determines which set of Resources are used in the UI
//So, if the CurrentUICulture is set to US English, it will look for the resource assembly that has the same designation
...
Both of these properties are setable, this means that we can change the culture programmatically.
#There is exception for Windows Store Apps
CurrentCulture
For .NET 4.0 or later, this can be specific culture or neutral culture
Prior to .NET 4.0, this must be a specific culture (no neutral cultures allowed)
Is we only have a neutral culture we can call the CreateSpecificCulture method
var specficCulture = CultureInfo.CreateSpecificCulture("en")
Either way, if we use the neutral "en" culture, we will end up with a specific en-US culture
The reason we need a specific culture is that CurrentCulture...
Determines globalization formats for dates, numbers, and currency
Determines the sort order (how accented, or capitalized characters)
Determines parsing (such as DateTime.Parse)
Determines output formats such as DateTime.ToString("d")
Note : most parsing and output methods take an optional IFormatProvider parameter.
CurrentUICulture
Determines which culture-specific resources are used
This is how the resource manager knows which of the satellite assemblies should be used at run time
CurrentCulture can be a neutral or specific culture
CurrentCulture & CurrentUICulture
CurrentCulture and CurrentUICulture are almost always set to the same culture
This will make sure that we have consistency across our application
But they can be set to different values to support special cases.
e.g., French languages in US, "fr-US" does not exist
CurrentCulture = "en-US" to get US formatting (dates, currency)
CurrentUICulture = "fr" to get French language resources
e.g., create custom cultures
How does Culture Get Set?
Thread.CurrentTread.Current(UI)Culture = ??? Where is it come from?
CultureInfo.DefaultThreadCurrentCulture { get; set; }
CultureInfo.DefaultThreadCurrentUICulture { get; set; }
CultureInfo has static "Default" properties, both properties's default values are null
When set, these values are used for all new threads created in the application domain
When a thread is started, its Thread.CurrentThread.Current(UI)Culture is set to the DefaultThreadCurrent(UI)Culture.
If null, Current(UI)Culture is set based on the OS culture
Meaning, if we do nothing, we get the OS culture by default for desktop apps
For web apps, culture is based on the request header
Both CurrentCulture and CurrentUICulture properties on the Thread class are writable
This means that we can manually set the culture if we like as hardcoded value or value from configuration, or user preference setting in our database.
(하지만 UWP에선 Thread class에 접근할 수 없다.)
e.g., var culture = new CultureInfo("cs-CZ");
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
//Use the same culture for any newly created threads
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;
Summary (생략)
출처
이 모든 내용은 Pluralsight에 Jeremy Clark가 올린 'Localization and Globalization in .NET'라는 강의의 첫번째 챕터를 듣고 정리한 것입니다(https://app.pluralsight.com/library/courses/intro-to-localization-globalization-dotnet/table-of-contents). 제가 정리한 것보다 더 많은 내용과 Demo를 포함하고 있으며 최종 Summary는 생략하겠습니다. Microsoft 지원을 통해 한달간 무료로 Pluralsight의 강의를 들으실 수도 있습니다.
(Localization and Globalization in .NET) Globalization (0) | 2018.01.01 |
---|---|
(Localization and Globalization in .NET) Considerations (0) | 2018.01.01 |
.Net ecosystem (0) | 2017.12.03 |