2022年7月16日土曜日

GIMP 2.99 Python 寄り道 其の弐

少し気になる 記述 を見掛けました。  少し前の事です。
GIMP 2.99 の Localization 絡みの報告です。
Plug-in での扱いに言及されています。
知って置いて 損は無い と思いますので。


件の報告が 此方 になります。

Review how plug-in localization works
https://gitlab.gnome.org/GNOME/gimp/-/issues/8124

そして、注目したのが 此の部分。
https://gitlab.gnome.org/GNOME/gimp/-/issues/8124#note_1493890

引用しますね。

Ok I reviewed our code regarding argument localization. We were running gettext later for the "nick" part of argument (label), but not for the "blurb" part (tooltip). Anyway now, with commit 27b09104, we run it in no case. Plug-in devs are simply expected to take care of localization at argument creation.
I.e. for instance:

      GIMP_PROC_ARG_BOOLEAN (procedure, "perceptual-metric",
                             "Perceptual metric",
                             "Use a perceptual error metric during compression",
                             FALSE,
                             G_PARAM_READWRITE);
… should now be:

      GIMP_PROC_ARG_BOOLEAN (procedure, "perceptual-metric",
                             _("Perceptual metric"),
                             _("Use a perceptual error metric during compression"),
                             FALSE,
                             G_PARAM_READWRITE);
This is now much clearer. No more wondering. When do I use N_() and when do I use _()? Plug-in take care of localizing. Done.


上記の例示は C で Plug-in を書くケースだと思いますので、
例えば、Python の Plug-in ならば、以下の様なものが該当するのでしょうね。
(自前の Code から抜粋 既に投稿に上げたものから 類似のケースを抜粋)


class ShiroDialogArgs6TestApi3 (Gimp.PlugIn):
    ## Parameters ##
    __gproperties__ = {

        "is_ok": (bool,
                 _("  :  Is OK ? "),
                 _("Is OK ?  Tooltip"),
                 False,
                 GObject.ParamFlags.READWRITE),
    }



そう、昔から GIMP 2.99.x の Python Code Sample では 此の様な 記述になっていました。
興味がある方は GIMP 2.99.7 (?) 以降 の foggify.py をご覧下さい。

  管理者として Install したならば、以下の場所にありますね。
  C:¥Program Files¥GIMP 2.99¥lib¥gimp¥2.99¥plug-ins¥foggify
  コピペ用 文字列
  C:\Program Files\GIMP 2.99\lib\gimp\2.99\plug-ins\foggify
  
class Foggify (Gimp.PlugIn):
    ## Parameters ##
    __gproperties__ = {
        "name": (str,
                 _("Layer _name"),
                 _("Layer name"),
                 _("Clouds"),
                 GObject.ParamFlags.READWRITE),
    # Omitted below (以下省略)


そして、先の報告には 此の様な記述もあります。

Now there is the specific case of when we use int argument to be used instead of enum arguments because the PDB doesn't create custom enums. Right now, we are listing the values in the blurb text, which is bug-prone and also which won't work well with very long list.
And finally it sucks for localization.
I want to see if we can maybe add a consistent single way to add the valid value listing in the procedure declaration part.

大歓迎です!。

Python も、3.4 或いは 3.6 辺りから、
Enum 宣言が可能の様なので、
  (class Enum / IntEnum / Flag / IntFlag - Lib/enum.py)
どの様な実装になるのか、興味津々です。  ;)



0 件のコメント:

コメントを投稿