LanguageHandler



 
LanguageHandler is a Ruby class provided by SketchUp in their Ruby examples. It allows developers to create Ruby scripts which can be altered to display their text in other languages.

Languages

For each application the developer creates a .strings file, such as ExamplesEN.string, containing the translations for the desired language. "EN" here refers to English.
Valid values for the 2 language letters are: EN, QE, DE, FR, JP, ES, and IT.  



Usage

  1. First create a .strings file for you application and store it in the "plugins" folder.
    • For example, MyApplicationEN.strings.
    • The format of this file is: "string"="translated string";
    • (One translation per line)
    • In the EN version, (or the version for your native language), these two phrases are often the same.
  2. Then, in the .RB file which loads your application, add the line: require 'LangHandler.rb'
    • This insures that the LanguageHandler class will be loaded with your application.
  3. Then add the line: $xxStrings = LanguageHandler.new("MyApplication")
    • Where xx is a code for your application, and "MyApplication" is the base name you used when creating the .strings file.
  4. For any strings which are visible to your users, use $xxStrings.GetString("string")
    • For example: sub_menu.add_item($xxStrings.GetString("Lighting Options")) { RPS_Lights::light_options }

Notes:
  • If you use a string which is not defined in the .strings file, the original string will be returned.
 


File Locations

LanguageHandler is defined in "LangHandler.rb" which is usually found in the "plugins" folder of the SketchUp installation.



Examples

See "examples.rb" in the "plugins" folder for an example of the use of the LanguageHandler class.



See Also




Editing History

Render Plus August 21, 2006