0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

KiCadのfreeroutingプラグインのGUIの言語設定(暫定手段)

Last updated at Posted at 2023-04-04

この記事の前提とする版数情報

  • KiCad 7.0
  • freerouting 1.7.1

問題背景

KiCad で GUIの言語設定を変えるには Preferences の Set Language でできるわけだが、この変更した情報は kicad_common.json ファイルの "system" の "language"に保存されている。

KiCad の プラグインに freerouting というものがあるが、上記のKiCad で GUIの言語設定での設定変更が反映されない。

これはプラグインを呼び出すときにkicad_common.json ファイルの内容を一切参照していないためである。

解析

freerouting は javaで記載されているが、GUIの言語設定はコマンドラインまたは環境変数あるいはjavaの環境デフォルト値で変更することができるようになっている。

https://github.com/freerouting/freerouting/blob/master/src/main/java/app/freerouting/gui/StartupOptions.java
java.util.Locale.getDefaultのgetLanguageあるいは起動引数の-lオプションで外部から指定することができるようになっている。

freeroutingのKiCadプラグインの現在の実装では
https://github.com/freerouting/freerouting/blob/master/integrations/KiCad/kicad-freerouting/plugins/plugin.py

        # Run freerouting with logging disabled (-dl) and input (-de) and output (-do) file definition
        self.module_command = [self.java_path, "-jar", self.module_path, "-dl", "-de", self.module_input, "-do", self.module_output]

このようにjavaを起動しているため、kicad_common.json ファイルの内容を反映していない。

freeroutingのプラグインでGUIの言語設定を指定する手段(やっつけ)

KiCadプラグイン&コンテンツ マネージャーを起動してパッケージ ディレクトリを開くを選択し(Python script locations : https://docs.kicad.org/master/ja/pcbnew/pcbnew.html#scripting )、3rdparty の plugins の app_freerouting_kicad-plugin フォルダにある plugin.py ファイルを下記のように書き換える。

       # Run freerouting with logging disabled (-dl) and input (-de) and output (-do) file definition
#        self.module_command = [self.java_path, "-jar", self.module_path,"-dl", "-de", self.module_input, "-do", self.module_output]
        self.module_command = [self.java_path, "-Duser.language=ja -Duser.country=JP","-jar", self.module_path,"-dl", "-de", self.module_input, "-do", self.module_output]

"-Duser.language" 環境変数の代入値"ja" を適宜変更することで言語設定ができる。

または

        # Run freerouting with logging disabled (-dl) and input (-de) and output (-do) file definition
#        self.module_command = [self.java_path, "-jar", self.module_path,"-dl", "-de", self.module_input, "-do", self.module_output]
        self.module_command = [self.java_path, "-jar", self.module_path,"-l","ja","-dl", "-de", self.module_input, "-do", self.module_output]
 

起動引数の指定において"-l" 引数の次の"ja" を適宜変更することで言語設定ができる。

補足

freerouting で現在指定できるGUIの言語設定種は次のものがある

  String[] supported_languages = {"en", "de", "zh", "hi", "es", "fr", "ar", "bn", "ru", "pt", "ja", "ko"};

本来の修正すべき内容(案)

KiCadのGUIの言語設定をISO 639で記載した上で、プラグイン側でその値を参照できる様に共通のAPIを定義して、プラグイン側の固有の引数値を生成するようにすべきかなぁ。。。

これかなぁ...

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?