Linux あれこれ

Linux 関連(一部 Windows11 )の備忘録です。

Lubuntu 20.10 の「Update Notifier」と「Apply Full Upgrade」の国際化をプルリクエスト〈H108〉

登録日: 2021-01-21 更新日: 2021-01-29

「Lubuntu 20.10」をUSB メモリにインストール しました。

前回 は「Lubuntu 20.10」にてシステム更新を通知する「Update Notifier」と「Apply Full Upgrade」を独自に国際化対応してみました。

調べると、公式の GitHub でも、国際化は進んでいました:

lubuntu-team/lubuntu-update-notifier - GitHub

やり方も翻訳対象にする文字列も少し違いました。 少しでも貢献できればと前回の成果を反映できるかトライして、プルリクエストしました。

-

GitHub でのプルリクエストのやり方の例を後半に記述しました。 git 操作は奥が深くてリスクが高いので、記憶が薄れて忘れないための個人的な備忘録です。

git 操作での、下手な操作は自分だけでなく、他の人にも影響を与えるリスクがあることに注意です。 自己責任です。

-

「目次」

-

日本語化された「Update Notifier」画面:

↓ (呼び出し)

-

日本語化された「Apply Full Upgrade」画面:

-


GitHub での国際化:

参考:

lubuntu-team/lubuntu-update-notifier - GitHub

-

git clone で使うアドレス:

https://github.com/lubuntu-team/lubuntu-update-notifier.git

-

プログラム処理の流れ:

data/upg-notifier-autostart.desktop
↓
/usr/libexec/lubuntu-update-notifier/lubuntu-upg-notifier.sh
↓
/usr/lib/update-notifier/apt-check  ←(別パッケージ)
↓
/usr/libexec/lubuntu-update-notifier/lubuntu-notifier.py
↓
(/usr/share/applications/upg-apply.desktop) ←(メニューに登録あり)
↓
/usr/bin/lubuntu-upgrader

-


GitHub の「lubuntu-team/lubuntu-update-notifier」のソースをダウンロード:

-

1. 作業用に、~/Git/ フォルダ作成(任意)

$ cd
$ mkdir Git

-

2. git があるか確認:

$ git --version
git version 2.27.0

-

3. ソースをダウンロード:

$ cd ~/Git/

[~/Git]$ git clone https://github.com/lubuntu-team/lubuntu-update-notifier.git

[~/Git]$ cd ~/Git/lubuntu-update-notifier/

[~/Git/lubuntu-update-notifier]$ ls -a
.       helper                   po
..      lubuntu-notifier.py      resources
.git    lubuntu-update-notifier  setup.cfg
data    lubuntu-upg-notifier.sh  setup.py
debian  lubuntu-upgrader         translation_helper

→git コマンドを使う場合、「.git 」があるのがポイントです。 git コマンドを使うときに重要になるので、コマンドプロンプトにワーキングディレクトリ名も表記。

-


「data/upg-apply.desktop」への反映:

$ cp ~/Git/lubuntu-update-notifier/data/upg-apply.desktop ~/ダウンロード/翻訳/upg-apply.desktop
$ featherpad ~/ダウンロード/翻訳/upg-apply.desktop

下記の2行を追記:

Name[ja]=すべてのアップグレードの適用 (Apply Full Upgrade)
Comment[ja]=すべてのアップグレードの検索と適用

[Desktop Entry]
Exec=lxqt-sudo /usr/bin/lubuntu-upgrader --cache-update --full-upgrade
Name=Apply Full Upgrade
Name[ja]=すべてのアップグレードの適用 (Apply Full Upgrade)
GenericName=Apply Full Upgrade
Comment=Search and Apply Full Upgrade
Comment[ja]=すべてのアップグレードの検索と適用
Icon=system-software-update
Type=Application
Version=0.1
Categories=System;Settings;
Keywords=upgrade;update
Terminal=false

-


「lubuntu-notifier.py」への反映:

-

~/Git/lubuntu-update-notifier/lubuntu-notifier.py の差分の確認:

  • Lubuntu 20.10 を国際化したときに比べ、どれくらい修正がされているかを確認:
$ diff ~/ダウンロード/翻訳/lubuntu-notifier.py-ORG ~/Git/lubuntu-update-notifier/lubuntu-notifier.py

100,103c116,127
<                     pkg_upgrade.append(p.name)
<             text = "There are upgrades available. Do you want to do a system"
<             text += " upgrade?\nThis will mean packages could be upgraded,"
<             text += " installed, or removed."
---
>                     pkg_upgrade.append([p, self.depcache.get_candidate_ver(p)])
>             text = _("There are upgrades available. Do you want to do a system"
>                      " upgrade?")
>             text += "\n"
>             text += _("This will mean packages could be upgraded, installed or"
>                       " removed.")
>             if self.security_upgrades > 0:
>                 text += "\n" + str(self.security_upgrades)
>                 if self.security_upgrades == 1:
>                     text += _(" is a security upgrade.")
>                 else:
>                     text += _(" are security upgrades.")

197a237,242
>     localesApp = "lubuntu-update-notifier"
>     localesDir = "/usr/share/locale"
>     gettext.bindtextdomain(localesApp, localesDir)
>     gettext.textdomain(localesApp)
>     _ = gettext.gettext
> 

→上記は表示された差分を前回作成の「lubuntu-notifier-CHG.py」と比較して翻訳対象の同じ文字列を除去したものです。

少しだけ翻訳対象の文字列が増えていました。翻訳しやすい位置に同じように行分割されています。国際化のやり方は少し違い、ドメイン名は「lubuntu-update-notifier」です。

  • これなら、翻訳対象の追加をする必要はないみたい。

-


「lubuntu-upgrader」への反映:

-

1. 「~/Git/lubuntu-update-notifier/lubuntu-upgrader」の差分の確認:

$ diff ~/ダウンロード/翻訳/lubuntu-upgrader-ORG ~/Git/lubuntu-update-notifier/lubuntu-upgrader

- 下記の「of」は翻訳しないでおくのがベターかも

186,187c186,187
<             if self.detailText != "Fetching " + str(
<                     current_items) + " of " + str(total_items):
---
>             if self.detailText != _("Fetching") + str(
>                     current_items) + " " + _("of") + " " + str(total_items):

189,190c189,190
<                     "Fetching " + str(current_items) + " of "
<                     + str(total_items)
---
>                     _("Fetching") + " " + str(current_items) + " " + _("of") +
>                     " " + str(total_items)

199,200c199,200
<             if self.detailText != "Downloaded " + str(
<                     current_items) + " of " + str(total_items):
---
>             if self.detailText != _("Downloaded") + " " + str(
>                     current_items) + " " + _("of") + " " + str(total_items):

202,203c202,203
<                     "Downloaded " + str(current_items) + " of "
<                     + str(total_items)
---
>                     _("Downloaded") + " " + str(current_items) + " " +
>                     _("of") + " " + str(total_items)

-

378a379,384
>     localesApp ="lubuntu-update-notifier"
>     localesDir ="/usr/share/locale"
>     gettext.bindtextdomain(localesApp, localesDir)
>     gettext.textdomain(localesApp)
>     _ = gettext.gettext
> 

→上記は、表示された差分を前回作成した「lubuntu-upgrader-CHG.py」と比較して翻訳対象の同じ文字列を除去したものです。

国際化のやり方は違い、ドメイン名は「lubuntu-update-notifier」です。 日本語での翻訳が難しい対象が含まれています。 「of」は前後の語順が固定だと、そのまま「の」に翻訳されると意味が反転します。 ここでは「が実行中でそれが含まれるのは」の意味。「 / 」に翻訳したけどどうなのかな。 翻訳時に前後が見えないかもしれないので、再び「の」に戻されるとつらいところ。

-

2. 先頭のライセンス部分を表示:

$ cat ~/Git/lubuntu-update-notifier/lubuntu-upgrader

#!/usr/bin/python3
# coding=utf-8

# Copyright (C) 2019 Hans P. Möller <hmollercl@lubuntu.me>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

-

3. 翻訳対象を増やしました:

$ cp ~/Git/lubuntu-update-notifier/lubuntu-upgrader ~/ダウンロード/翻訳/lubuntu-upgrader-Git-ORG
$ cp ~/Git/lubuntu-update-notifier/lubuntu-upgrader ~/ダウンロード/翻訳/lubuntu-upgrader-Git

$ ls ~/ダウンロード/翻訳/lubuntu-upgrader-Git*          
/home/ubn/ダウンロード/翻訳/lubuntu-upgrader-Git                     
/home/ubn/ダウンロード/翻訳/lubuntu-upgrader-Git-ORG

$ featherpad ~/ダウンロード/翻訳/lubuntu-upgrader-Git

-

下記の差分を見ながら修正:
$ diff ~/Git/lubuntu-update-notifier/lubuntu-upgrader ~/ダウンロード/翻訳/lubuntu-upgrader-Git  ←(実行不要)

239c239
<         self.errors.append("Eror Code: " + str(error_code))
---
>         self.errors.append("Error Code: " + str(error_code))
243,244c243,244
<         print("ECode: " + str(error_code) + "\n")
<         print("EDetail: " + error_details + "\n")
---
>         print(_("ECode: ") + str(error_code) + "\n")
>         print(_("EDetail: ") + error_details + "\n")
269c269
<             print("Warning: install transaction not completed successfully:"
---
>             print(_("Warning: install transaction not completed successfully:")
313c313
<             print("Status Details:" + details)
---
>             print(_("Status Details:") + details)
345c345
<             print("Warning: install transaction not completed successfully:"
---
>             print(_("Warning: install transaction not completed successfully:")

-


「po/lubuntu-update-notifier.pot」への反映:

「translation_helper」ファイルに書かれた内容を参考にして、2つのPython プログラムをまとめてPOT ファイル「po/lubuntu-update-notifier.pot」を作成します。

-

1. 「.pot ファイル」の作成:

$ cd ~/ダウンロード/翻訳/
$ mkdir translations
$ cd ~/ダウンロード/翻訳/translations/
$ mkdir ja

$ cp ~/Git/lubuntu-update-notifier/lubuntu-notifier.py lubuntu-notifier.py
$ cp ~/ダウンロード/翻訳/lubuntu-upgrader-Git lubuntu-upgrader
$ ls
lubuntu-notifier.py  lubuntu-upgrader  ja

$ xgettext lubuntu-upgrader lubuntu-notifier.py --language=Python
$ mv messages.po ja/lubuntu-update-notifier.pot
$ ls ja/
lubuntu-update-notifier.pot

→2つのPython プログラムをまとめてPOT ファイル「po/lubuntu-update-notifier.pot」を作成。

-

2. 「.pot ファイル」の修正:

$ cd ~/ダウンロード/翻訳/translations/ja/
$ featherpad lubuntu-update-notifier.pot

17 行目を修正:

"Content-Type: text/plain; charset=CHARSET\n"

"Content-Type: text/plain; charset=UTF-8\n"

→コード指定していないとコンパイルのときに停止します。

-


「po/ja.po」への反映:

-

1. 「.po ファイル」を翻訳(編集)

$ cd ~/ダウンロード/翻訳/translations/ja/
$ cp lubuntu-update-notifier.pot lubuntu-update-notifier.po

$ featherpad lubuntu-update-notifier.po

→先頭のコメント部は大幅に削除:

-

2. 翻訳後の確認:

$ cat ~/ダウンロード/翻訳/translations/ja/lubuntu-update-notifier.po

msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-19 22:14+0900\n"
"PO-Revision-Date: 2021-01-19 23:30+0900\n"
"Last-Translator: FuRuYa7\n"
"Language-Team: Japanese\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"

#: lubuntu-upgrader:129
msgid "Updating cache..."
msgstr "キャッシュを更新中..."

#: lubuntu-upgrader:186 lubuntu-upgrader:189
msgid "Fetching"
msgstr "読み出し中"

#: lubuntu-upgrader:187 lubuntu-upgrader:189 lubuntu-upgrader:200
#: lubuntu-upgrader:203
# "「の」に翻訳すると意味が反転するので注意"
msgid "of"
msgstr " / "

#: lubuntu-upgrader:199 lubuntu-upgrader:202
msgid "Downloaded"
msgstr "ダウンロード済みです"

#: lubuntu-upgrader:214 lubuntu-notifier.py:204
msgid "Upgrade finished"
msgstr "アップグレードが完了しました"

#: lubuntu-upgrader:218 lubuntu-notifier.py:169 lubuntu-notifier.py:173
#: lubuntu-notifier.py:208
msgid "Reboot required"
msgstr "再起動が必要です"

#: lubuntu-upgrader:222
msgid "With some Errors"
msgstr "いくつかのエラーがあります"

#: lubuntu-upgrader:223
msgid "Error Resume:"
msgstr "エラー再開:"

#: lubuntu-upgrader:243
msgid "ECode: "
msgstr "エラーコード: "

#: lubuntu-upgrader:244
msgid "EDetail: "
msgstr "エラーの詳細: "

#: lubuntu-upgrader:269 lubuntu-upgrader:345
msgid "Warning: install transaction not completed successfully:"
msgstr "警告: インストール処理が正常に完了しませんでした:"

#: lubuntu-upgrader:274
msgid "Update Cache Finished"
msgstr "キャッシュの更新が完了しました"

#: lubuntu-upgrader:313
msgid "Status Details:"
msgstr "ステータスの詳細:"

#: lubuntu-upgrader:369
msgid ""
"Please run this software with administrative rights.To do so, run this "
"program with lxqt-sudo."
msgstr "管理者権限で実行してください。lxqt-sudo を使用して実行します。"

#: lubuntu-upgrader:391
msgid "Update Cache Before Upgrade"
msgstr "アップグレード前にキャッシュを更新します"

#: lubuntu-upgrader:396
msgid "Full upgrade same as dist-upgrade"
msgstr "dist-upgrade と同じ完全アップグレード"

#: lubuntu-notifier.py:54
#, python-format
msgid "Error: Opening the cache (%s)"
msgstr "エラー: キャッシュ (%s) を開いています"

#: lubuntu-notifier.py:71 lubuntu-notifier.py:77
msgid "Affected Packages"
msgstr "影響を受けるパッケージ"

#: lubuntu-notifier.py:72
msgid "Security"
msgstr "セキュリティ"

#: lubuntu-notifier.py:117
msgid "There are upgrades available. Do you want to do a system upgrade?"
msgstr "利用可能なアップグレードがあります。システムのアップグレードを行いますか?"

#: lubuntu-notifier.py:120
msgid "This will mean packages could be upgraded, installed or removed."
msgstr "パッケージがアップグレード、インストール、または削除されます。"

#: lubuntu-notifier.py:125
msgid " is a security upgrade."
msgstr " 個がセキュリティのアップグレードです。"

#: lubuntu-notifier.py:127
msgid " are security upgrades."
msgstr " 個がセキュリティのアップグレードです。"

#: lubuntu-notifier.py:130
msgid "Remove"
msgstr "削除"

#: lubuntu-notifier.py:137
msgid "Install"
msgstr "インストール"

#: lubuntu-notifier.py:152
msgid "Upgrade"
msgstr "アップグレード"

#: lubuntu-notifier.py:194
msgid "Upgrading..."
msgstr "アップグレード中..."

#: lubuntu-notifier.py:247
msgid "Define software/app to open for upgrade"
msgstr "アップグレードで開くソフトウェア/アプリを定義します"

#: lubuntu-notifier.py:252
msgid "How many upgrades are available"
msgstr "利用可能なアップグレードの数"

#: lubuntu-notifier.py:257
msgid "How many security upgrades are available"
msgstr "利用可能なセキュリティアップグレードの数"

-

3. 「.mo ファイル」にコンパイル

$ cd ~/ダウンロード/翻訳/translations/ja/
$ msgfmt lubuntu-update-notifier.po -o lubuntu-update-notifier.mo

→出力ファイル名を指定しないと「messages.mo」になります。

$ ls -1
lubuntu-update-notifier.mo
lubuntu-update-notifier.po
lubuntu-update-notifier.pot

-

4. 「.mo ファイル」を配置:

$ cd ~/ダウンロード/翻訳/translations/ja/
$ sudo cp lubuntu-update-notifier.mo /usr/share/locale/ja/LC_MESSAGES/

確認:

$ ls /usr/share/locale/ja/LC_MESSAGES/lubuntu*

/usr/share/locale/ja/LC_MESSAGES/lubuntu-notifier2.mo      ←(前回 1/2)
/usr/share/locale/ja/LC_MESSAGES/lubuntu-update-notifier.mo ←(今回はひとつのファイルのみ)
/usr/share/locale/ja/LC_MESSAGES/lubuntu-upgrader2.mo  ←(前回 2/2)

-


動作テストのための配置:

  • 動作を確認には、プログラムの配置が必要です。Git フォルダでそのまま行うと、プルリクエストする前にソースのフォルダが汚れてしまいます。すでに配置が終わっているファイルもありますが、整理するため、再度実施しました。
$ cd /usr/libexec/lubuntu-update-notifier/
$ ls ~/ダウンロード/翻訳/lubuntu-upg-notifier.sh-ORG
$ sudo cp lubuntu-upg-notifier.sh ~/ダウンロード/翻訳/lubuntu-upg-notifier.sh-ORG  ←(最初の1回のみ)

$ sudo cp ~/Git/lubuntu-update-notifier/lubuntu-upg-notifier.sh lubuntu-upg-notifier.sh
$ sudo cp ~/Git/lubuntu-update-notifier/lubuntu-notifier.py lubuntu-notifier.py
$ sudo cp ~/ダウンロード/翻訳/lubuntu-upgrader-Git /usr/bin/lubuntu-upgrader
$ sudo cp ~/ダウンロード/翻訳/upg-apply.desktop /usr/share/applications/upg-apply.desktop

$ cd ~/ダウンロード/翻訳/translations/ja/
$ sudo msgfmt lubuntu-update-notifier.po -o /usr/share/locale/ja/LC_MESSAGES/lubuntu-update-notifier.mo

再起動

-

動作テスト

作業中に、システム更新の通知があったら、システム更新せずに閉じておきます。 そうすれば、再起動してすぐか、 1時間ほどで通知のダイアログが表示されると思います。

-

もしくは、

設定→「すべてのアップグレードの適用」→「すべてのアップグレード」画面

→日本語化されていることを確認。

-


動作確認できたので、成果をソースに反映:

$ cd ~/ダウンロード/翻訳/
$ sudo cp upg-apply.desktop ~/Git/lubuntu-update-notifier/data/upg-apply.desktop
$ sudo cp lubuntu-upgrader-Git ~/Git/lubuntu-update-notifier/lubuntu-upgrader

$ cp translations/ja/lubuntu-update-notifier.pot ~/Git/lubuntu-update-notifier/po/
$ cp translations/ja/lubuntu-update-notifier.po ~/Git/lubuntu-update-notifier/po/ja.po

-

git の状態を確認:

$ cd ~/Git/lubuntu-update-notifier/
[~/Git/lubuntu-update-notifier]$

[~/Git/lubuntu-update-notifier]$ git status
ブランチ master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   data/upg-apply.desktop
        modified:   lubuntu-upgrader
        modified:   po/lubuntu-update-notifier.pot

追跡されていないファイル:
  (use "git add <file>..." to include in what will be committed)
        po/ja.po

no changes added to commit (use "git add" and/or "git commit -a")

→修正が 3個、追加が 1個になっています。

-


参考: 反映されたソースからの国際化:

  • 最終的には、反映されたソース(もしくはダウンロード直後のソースに po/ja.po を追加するだけでも可)から国際化できます。
$ cd ~/Git/lubuntu-update-notifier/
$ sudo cp lubuntu-upg-notifier.sh /usr/libexec/lubuntu-update-notifier/lubuntu-upg-notifier.sh
$ sudo cp lubuntu-notifier.py /usr/libexec/lubuntu-update-notifier/lubuntu-notifier.py
$ sudo cp lubuntu-upgrader /usr/bin/lubuntu-upgrader
$ sudo cp data/upg-apply.desktop /usr/share/applications/upg-apply.desktop

$ sudo msgfmt po/ja.po -o /usr/share/locale/ja/LC_MESSAGES/lubuntu-update-notifier.mo

-


プルリクエストを行う準備:

日本語で表示できることを確認できたら、 「プルリクエストすることを前提」にしたやり方で git clone しました。

-

1. プルリクエスト用のフォルダを準備:

$ cd
$ mkdir Git2
$ cd ~/Git2/

→今までとフォルダ名が違うことに注目。

-

2. 対象の「GitHubリポジトリ」(GitHub の該当サイト)をブラウザで開きます

lubuntu-team/lubuntu-update-notifier - GitHub

-

3. GitHub アカウントにサインイン

今回は「GitHub アカウント」が必要です。(すでに作成済みとします)

-

ページ右上の「横3本」をクリック→「Sign in」→「Sign in to GitHub」画面

→登録している「Eメールアドレス」と「パスワード」を入力して、サインインします。

→サインインされると、画面右上に自分が登録した、自分のアイコン(アバター)が表示されます。

表示が変わらない時は、先程のメールを確認して下さい。コードを控えて待機画面に入力。

-

4. 「Fork」ボタンを押すことで、自分のアカウントに対象のリポジトリをFork :

→しばらく待つと、画面が自分の画面に変わります。

 lubuntu-team / lubuntu-update-notifier 

↓ 画面が自分の画面に変わります。

MY_NAME / lubuntu-update-notifier
forked from lubuntu-team/lubuntu-update-notifier 

→自分の「MY_NAME / lubuntu-update-notifier」のサイトのアドレス、および、clone のアドレスを控えておきます。 ブラウザのブックマークに登録してもよいです。

https://github.com/MY_NAME/lubuntu-update-notifier
https://github.com/MY_NAME/lubuntu-update-notifier.git

-

5. 自分のPC で、作成された自分のリモートリポジトリを指定して git clone :

自分のリモートリポジトリから、(その時点で)最新のソースを入手:

$ cd ~/Git2/
[~/Git2]$ git clone https://github.com/MY_NAME/lubuntu-update-notifier.git

clone(ローカルに保存)したディレクトリに移動:

[~/Git2]$ cd ~/Git2/lubuntu-update-notifier/
[~/Git2/lubuntu-update-notifier]$ git status
ブランチ master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

→通常は「origin/Master」であることが多いです。

-

6. プルリクエスト用に Branch「develop」を作成:

何かあったときの他の人への影響を少なくできます。 また、自分の位置の確認にもなります。

[~/Git2/lubuntu-update-notifier]$ git checkout -b develop
Switched to a new branch 'develop'

[~/Git2/lubuntu-update-notifier]$ git status
ブランチ develop
nothing to commit, working tree clean

→「develop」に変わったことを確認。現在はコミットできるものはなし、作業ツリーは空です。

-

7. この時点から、Cloneしたディレクトリにある(関連する)ファイルを編集できます:

-


成果を git clone したソース(~/Git2/lubuntu-update-notifier/) に反映:

  • 変更(diff)を少なくするため、さわるファイルは最小限にします。 日時で更新を確認できます。

-

1. 成果をソースに反映:

$ cd ~/ダウンロード/翻訳/
$ sudo cp upg-apply.desktop ~/Git2/lubuntu-update-notifier/data/upg-apply.desktop
$ sudo cp lubuntu-upgrader-Git ~/Git2/lubuntu-update-notifier/lubuntu-upgrader

$ cp translations/ja/lubuntu-update-notifier.pot ~/Git2/lubuntu-update-notifier/po/
$ cp translations/ja/lubuntu-update-notifier.po ~/Git2/lubuntu-update-notifier/po/ja.po

-

2. git を確認:

$ cd ~/Git2/lubuntu-update-notifier/
[~/Git2/lubuntu-update-notifier]$ git status

ブランチ develop
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   data/upg-apply.desktop
        modified:   lubuntu-upgrader
        modified:   po/lubuntu-update-notifier.pot

追跡されていないファイル:
  (use "git add <file>..." to include in what will be committed)
        po/ja.po

no changes added to commit (use "git add" and/or "git commit -a")

→赤色が修正したファイル数と同じであれば、OK。

  • エディタの「~」付きのバックアップファイルがないか確認。

→あったら削除しておきます。 ファイルマネージャでCtrl+H すれば表示されるので、削除。

-

日本語の表題:
日本語対応のための修正が 3つ、追加が 1つあります。

1. 「.desktop」ファイルは、日本語を追加しました。
2. 「.desktop」ファイルは、翻訳対象の文字列を追加しました。
3. 「.pot」ファイルは、「charset=UTF-8」に修正して、追加も含めて再作成しました。
4. 日本語の「.po」ファイルを追加しました。

-

英訳:
There are 3 fixes and 1 addition for Japanese support.

1. Japanese has been added to the "data/upg-apply.desktop" file.

2. The "lubuntu-upgrader" file has added the character string to be translated.

3. The "po/lubuntu-update-notifier.pot" file was modified to "charset = UTF-8" and recreated, including additions.

4. Added Japanese "po/ja.po" file.

→早めに英文を作成しておきます。

-

6. 編集したファイルを add:

  • 「編集エリア」(working tree) から「ステージングエリア」に移します。
[~/Git2/lubuntu-update-notifier]$ git add -A

[~/Git2/lubuntu-update-notifier]$ git status
ブランチ develop
コミット予定の変更点:
  (use "git restore --staged <file>..." to unstage)
        modified:   data/upg-apply.desktop    ←(4個すべてが緑色に変わりました)
        modified:   lubuntu-upgrader
        new file:   po/ja.po
        modified:   po/lubuntu-update-notifier.pot

-

7. commit の前に、git の環境設定をしておきます:

登録は最初に 1回やるだけ:

[~/Git2/lubuntu-update-notifier]$ git config --global user.email "MY_EMAIL@MAIL.com"
[~/Git2/lubuntu-update-notifier]$ git config --global user.name "MY_NAME"

-

8. 編集したファイルを commit:

  • 「ステージングエリア」から「本番エリア」に移します:
[~/Git2/lubuntu-update-notifier]$ git commit -m "There are 3 fixes and 1 addition for Japanese support."

[develop d3ea83f] There are 3 fixes and 1 addition for Japanese support.
 4 files changed, 195 insertions(+), 21 deletions(-)
 create mode 100644 po/ja.po

→和訳: 日本語サポートには 3つの修正と1つの追加があります。

[~/Git2/lubuntu-update-notifier]$ git status
ブランチ develop
nothing to commit, working tree clean

→commit がうまくいくと、送るもの(commit できるもの)がなくなります。

-

9. 「developブランチ」から、Github上の「originブランチ」にpush します

ローカルで編集したレポジトリをオンライン上に渡します:

$ git push origin develop

Username for 'https://github.com': MY_NAME  ←(ユーザ名入力)
Password for 'https://MY_NAME@github.com':   ←(パスワード入力)

Enumerating objects: 14, done.
Counting objects: 100% (14/14), done.
Delta compression using up to 2 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 2.12 KiB | 2.12 MiB/s, done.
Total 8 (delta 5), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (5/5), completed with 4 local objects.
remote: 
remote: Create a pull request for 'develop' on GitHub by visiting:
remote:      https://github.com/MY_NAME/lubuntu-update-notifier/pull/new/develop
remote: 
To https://github.com/MY_NAME/lubuntu-update-notifier.git
 * [new branch]      develop -> develop

→develop ブランチの使用の初回のメッセージが表示されます。2回目からは表示が短くなります。

-

10. 確認:

$ git log

→リモートリポジトリとの更新履歴が見れます。 最新は上の方に表示されます。下方向は過去の履歴です。 スペースで改ページ。

commit d36483f65172f61b1e838639257258a9705baff654 (HEAD -> develop, origin/develop)
Author: MY_NAME <abcxxx@xxxxxxx.com>
Date:   Wed Jan 20 22:45:31 2021 +0900

    There are 3 fixes and 1 addition for Japanese support.

commit 73448df6db773ab26e26445e28d4e3ed296d0948 (origin/master, origin/HEAD, master)
Author: Hans P. Möller <hmollercl@lubuntu.me>
Date:   Sun Nov 8 16:20:05 2020 -0300

    update changelog
:

→半角の「q」で終了。

-


Github 上で、PullRequest します

  • ブラウザで自分のリポジトリ(MY_NAME / lubuntu-update-notifier) のサイトを開きます。

→ブックマークを登録しておけば楽です。

-

1. 右中(develop の行の右)の大きな緑色の「Compare & pull request」ボタンをクリック

→本家リポジトリ「lubuntu-team/lubuntu-update-notifier」のサイトに切り替わるので注意。

  • 最近、GitHub の表示フォーマットが変わって、ちょっと探してしまいます。でも使いやすくなったみたい。

  • もしなければ、master を develop に切り替えて、「Compare」ボタンをクリック

→Base: をダウンロードしたブランチ(MY_NAME-develope) に切り替えます。

  • 何度もCommente を入力すると、いくつもコメントが出来ておかしくなります。注意。

  • 修正したファイルごとにある「Load diff」ボタンを押して、差分を確認。

→今回は、下にスクロールするだけで、ボタン無しで確認できました。

-

2. どういった変更を加えたのかを説明する内容(コメント)を英語で記入

  • 表題は、先程のcommit のメッセージが登録されています。
There are 3 fixes and 1 addition for Japanese support.
  • 中身だけ記入します。記入は任意です。
There are 3 fixes and 1 addition for Japanese support.

1. Japanese has been added to the "data/upg-apply.desktop" file.

2. The "lubuntu-upgrader" file has added the character string to be translated.

3. The "po/lubuntu-update-notifier.pot" file was modified to "charset = UTF-8" and recreated, including additions.

4. Added Japanese "po/ja.po" file.

→いつもなら、表題だけで意味が通るので記入は不要ですが、今回は複数のファイルを同時に送ったので、ファイルごとに何を行ったか追記しました。フォルダ名も記入しています。後で自分で見直すときもコメントがあると便利です。

-

3. どのブランチからどのブランチにpull request されるかを確認します。

コメントを付けた上段の表示を確認。(2段表示に変更されたみたい)

[master] <--- [develop]

→※develop ブランチからmaster ブランチへのpull request

自分は「develop」で作業しているのでわかりやすいです。

-

4. 右下の緑色の「Create pull request」ボタンを押して、Pull Request を作成します。

-

5. あとは、ヘタに触りません。数日後のメールを待ちます。

「レポジトリ管理者」がコードを確認、OK ならMerge (取り込み)を実行してくれます。 忘れたころにメールは来ます。翌週だったり、2ヶ月後だったり、メールが来なかったりです。

  • 修正依頼が来るかもしれないので、プルリクエストに使った「~/Git2/」フォルダは触らずに保存しておきます。 今回、自分が修正した内容などの記録をメモとして残しておくとよいです。(自分はブログに残しました) 最初に作成した動作確認用の「~/Git/」フォルダは自由に操作できます。

-

-


まとめ

GitHub で進められている国際化にプルリクエストしてみました。送れたのはせいぜい.po ファイルくらいですが、少しでも貢献できればと思います。

プルリクエストも最近行っていないので記憶が飛んでいます。 備忘録も兼ねて、投稿しました。最近の翻訳は翻訳サイトで行うことが多いので、プルリクエストの回数も減りました。

ただし、今回のように翻訳対象を増やすなどのアプリ側の修正が伴うときはプルリクエストが必要です。

-

SSH」接続でプルリクエストするときは「こちら 」も参照。

-

-


目次

先頭

-


-