Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:sdksamples:determinecurrentlanguage [2015/09/14] (current)
Line 1: Line 1:
 +====== How To: Determine Rhino'​s Language Setting ======
 +====== C++, .NET ======
 +> **Summary:​** //How to determine Rhino'​s current language setting when developing localized plug-ins.//
 +> **NOTICE:** //The Rhino.NET SDK is deprecated in Rhino 5.  This example adapted for the new RhinoCommon SDK is [[developer:​rhinocommonsamples:​determinecurrentlanguage|here]]//​
 +
 +Rhino provides support for multiple languages. And, Rhino'​s language setting is independent of the operating system'​s language setting. Thus, as a plug-in developer, knowing Rhino'​s current language setting is important if you plan on supporting multiple languages.
 +
 +=====More Information=====
 +Rhino stores it's current Locale ID (LCID) in a CRhinoAppAppearanceSettings object that is held within Rhino applications settings object, or CRhinoAppSettings.
 +
 +=====Example=====
 +The following is an example of how to determine Rhino'​s current language setting.
 +
 +===== C++ =====
 +<code c++>
 +ON_wString wstr;
 +CRhinoAppSettings settings = ::​RhinoApp().AppSettings();​
 +CRhinoAppAppearanceSettings appearance = settings.AppearanceSettings();​
 +
 +switch( appearance.m_language_identifier )
 +{
 +case 1028: // zh-tw
 +  wstr = L"​Chinese - Taiwan";​
 +  break;
 +case 1029: // cs
 +  wstr = L"​Czech";​
 +  break;
 +case 1031: // de-de
 +  wstr = L"​German - Germany";​
 +  break;
 +case 1033: // en-us
 +  wstr = L"​English - United States";​
 +  break;
 +case 1034: // es-es
 +  wstr = L"​Spanish - Spain";​
 +  break;
 +case 1036: // fr-fr
 +  wstr = L"​French - France";​
 +  break;
 +case 1040: // it-it
 +  wstr = L"​Italian - Italy";​
 +  break;
 +case 1041: // ja
 +  wstr = L"​Japanese";​
 +  break;
 +case 1042: // ko
 +  wstr = L"​Korean";​
 +  break;
 +case 1045: // pl
 +  wstr = L"​Polish";​
 +  break;
 +case 2052: // zh-cn
 +  wstr = L"​Chinese - China";​
 +  break;
 +default:
 +  wstr = L"​unknown";​
 +  break;
 +}
 +::​RhinoApp().Print( L"The current language is \"%s\ , wstr );
 +</​code>​
 +===== VB.NET =====
 +<code vb>
 +Public Overrides Function RunCommand(ByVal context As IRhinoCommandContext) _
 +  As IRhinoCommand.result
 +
 +  Dim settings As MRhinoAppSettings = RhUtil.RhinoApp.AppSettings
 +  Dim appearance As IRhinoAppAppearanceSettings = settings.AppearanceSettings()
 +  Dim id As Integer = CType(appearance.m_language_identifier,​ Integer)
 +  Dim culture As New System.Globalization.CultureInfo(id)
 +  RhUtil.RhinoApp.Print("​The current language is " + culture.EnglishName + vbCrLf)
 +  Return IRhinoCommand.result.success
 +End Function
 +</​code>​
 +===== C# =====
 +<code c#>
 +public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
 +{
 +  MRhinoAppSettings settings = RhUtil.RhinoApp().AppSettings();​
 +  IRhinoAppAppearanceSettings appearance = settings.AppearanceSettings();​
 +
 +  int id = (int)appearance.m_language_identifier;​
 +  System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo(id);​
 +  RhUtil.RhinoApp().Print( "The current language is " + culture.EnglishName + "​\n"​ );
 +  return IRhinoCommand.result.success;​
 +}
 +
 +</​code>​
 +
 +
 +{{tag>​Developer cplusplus dotnet}}
  
developer/sdksamples/determinecurrentlanguage.txt ยท Last modified: 2015/09/14 (external edit)