Can a strings file be reloaded


#1

Reloading a rb file is easy.
But, doing localisations, is there a way to reload a string file.
I’m tired of quit-relaunch SU to check string swapping.


#2

The only way is to create a new LanguageHandler object and assign
the old reference (that is ponting at the old object) to the new object.

module Chabo
  module Plugin

    extend self
    @@loaded = false

    def load_strings
      @@say = LanguageHandler.new('chabo_plugin.strings')
    end

    load_strings() if !@@loaded

    def say(text)
      @@say[text]
    end

    if !@@loaded
      # define menus and commands
      @@loaded = true
    end

  end
end

… then to load the strings into a new LanguageHandler object, call …
Chabo::Plugin.load_strings … from the console.


However, this will not change native GUI text objects for commands that are only set when first created.
(Ie, menu item texts, toolbar tooltips, extension properties in SU2016 and earlier in the Preferences dialog, etc.)
The only way to see the language changes to menus and toolbars is to restart SketchUp.

But it can work for WebDialogs if you also write a method to refresh their content.