Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/multilanguage #177

Merged
merged 5 commits into from
Sep 13, 2024
Merged

Feat/multilanguage #177

merged 5 commits into from
Sep 13, 2024

Conversation

bordoray
Copy link
Collaborator

@bordoray bordoray commented Sep 11, 2024

Issue

close #176
related #105 #163

変更内容:Description

  • Check UI and Process messages in Japanese and English environment.
  • Check Help button to throw to Github readme.

Summary by CodeRabbit

  • 新機能

    • QGISプラグインのための英語と日本語の翻訳ファイルを追加しました。
    • ヘルプボタンを追加し、READMEページを開く機能を実装しました。
  • バグ修正

    • ユーザーインターフェースのエラーメッセージと通知を改善しました。
  • ドキュメント

    • ユーザーインターフェースのテキストを日本語から英語に翻訳しました。
    • プログレスダイアログのテキストを更新し、より明確にしました。

@bordoray bordoray requested a review from nbayashi September 11, 2024 04:42
Copy link

coderabbitai bot commented Sep 11, 2024

Walkthrough

このプルリクエストでは、QGISプラグインの国際化を強化するために、英語と日本語の翻訳ファイルを新たに追加しました。また、ユーザーインターフェースの改善として、新しいボタンやメッセージの翻訳機能が実装され、ユーザーがより良い体験を得られるようにしました。さらに、プロジェクトファイルが追加され、プラグインのビルド構成が整理されました。

Changes

ファイル 変更概要
i18n/QGIS2PlugX_en.ts 英語の翻訳ファイルを追加。UIコンポーネントのコンテキストを定義。
i18n/QGIS2PlugX_ja.ts 日本語の翻訳ファイルを追加。UIコンポーネントのコンテキストを定義。
qgis2plugx.pro プロジェクトファイルを追加。ソースファイル、UIフォーム、翻訳ファイルを指定。
qgis2plugx.py ローカリゼーションサポートを追加。ユーザーのロケール設定に基づいて翻訳ファイルを読み込む機能を実装。
translator/thread.py ProcessingThreadクラスにProgressDialogのインポートを追加。メッセージを英語に変更。
ui/main_dialog.py ヘルプボタンを追加し、メッセージの翻訳機能を実装。エラーメッセージを改善。
ui/main_dialog.ui 日本語のテキストを英語に翻訳。新しいヘルプボタンを追加。
ui/progress_dialog.py UIテキストのローカライズを実施。新しい翻訳機能を追加。
ui/progress_dialog.ui 日本語のテキストを英語に翻訳。ウィンドウタイトルやボタンテキストを変更。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Application
    participant Translator
    participant UI

    User->>Application: 起動
    Application->>Translator: ユーザーのロケールを取得
    Translator->>Application: 翻訳ファイルを読み込む
    Application->>UI: UIを表示
    User->>UI: ボタンをクリック
    UI->>Application: アクションを実行
    Application->>UI: 結果を表示
Loading

🐰 うさぎの詩 🐰
変更が加わり、楽しいこと、
英語と日本語、みんなのために。
ヘルプボタンも、役立つよ、
さあ、プラグインを使ってみよう!
うさぎも跳ねる、嬉しいニュース、
みんなで使おう、楽しいツール!
🌟✨


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1552612 and cfa0e57.

Files selected for processing (2)
  • translator/thread.py (1 hunks)
  • ui/main_dialog.py (6 hunks)
Files skipped from review as they are similar to previous changes (2)
  • translator/thread.py
  • ui/main_dialog.py

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1309653 and 1552612.

Files selected for processing (9)
  • i18n/QGIS2PlugX_en.ts (1 hunks)
  • i18n/QGIS2PlugX_ja.ts (1 hunks)
  • qgis2plugx.pro (1 hunks)
  • qgis2plugx.py (2 hunks)
  • translator/thread.py (2 hunks)
  • ui/main_dialog.py (6 hunks)
  • ui/main_dialog.ui (4 hunks)
  • ui/progress_dialog.py (3 hunks)
  • ui/progress_dialog.ui (3 hunks)
Files skipped from review due to trivial changes (2)
  • ui/main_dialog.ui
  • ui/progress_dialog.ui
Additional context used
Ruff
translator/thread.py

8-8: ui.progress_dialog.ProgressDialog imported but unused

Remove unused import: ui.progress_dialog.ProgressDialog

(F401)

ui/main_dialog.py

169-169: f-string without any placeholders

Remove extraneous f prefix

(F541)

GitHub Check: Lint
translator/thread.py

[failure] 8-8: Ruff (F401)
translator/thread.py:8:32: F401 ui.progress_dialog.ProgressDialog imported but unused

ui/main_dialog.py

[failure] 169-169: Ruff (F541)
ui/main_dialog.py:169:16: F541 f-string without any placeholders

Biome
i18n/QGIS2PlugX_en.ts

[error] 1-1: Expected a type but instead found '?'.

Expected a type here.

(parse)


[error] 1-1: expected : but instead found version

Remove version

(parse)


[error] 1-1: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 1-1: Expected an expression for the left hand side of the > operator.

This operator requires a left hand side value

(parse)


[error] 2-2: Expected a type but instead found '!'.

Expected a type here.

(parse)


[error] 2-2: expected : but instead found TS

Remove TS

(parse)


[error] 2-2: expected > but instead found version

Remove version

(parse)


[error] 2-2: Invalid assignment to TS><TS version

This expression cannot be assigned to

(parse)


[error] 4-4: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 6-6: expected > but instead found filename

Remove filename

(parse)


[error] 2-6: Invalid assignment to "2.0"> <context> <name>Dialog</name> <message> <location filename

This expression cannot be assigned to

(parse)


[error] 6-6: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 6-6: Expected an expression but instead found '>'.

Expected an expression here.

(parse)


[error] 7-7: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 8-8: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 8-8: Expected a type but instead found '/'.

Expected a type here.

(parse)


[error] 8-8: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 9-9: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 11-11: expected > but instead found filename

Remove filename

(parse)


[error] 8-11: Invalid assignment to "unfinished"></translation> </message> <message> <location filename

This expression cannot be assigned to

(parse)

i18n/QGIS2PlugX_ja.ts

[error] 1-1: Expected a type but instead found '?'.

Expected a type here.

(parse)


[error] 1-1: expected : but instead found version

Remove version

(parse)


[error] 1-1: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 1-1: Expected an expression for the left hand side of the > operator.

This operator requires a left hand side value

(parse)


[error] 2-2: Expected a type but instead found '!'.

Expected a type here.

(parse)


[error] 2-2: expected : but instead found TS

Remove TS

(parse)


[error] 3-3: expected > but instead found version

Remove version

(parse)


[error] 2-3: Invalid assignment to TS> <TS version

This expression cannot be assigned to

(parse)


[error] 3-3: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 5-5: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 7-7: expected > but instead found filename

Remove filename

(parse)


[error] 3-7: Invalid assignment to "ja"> <context> <name>Dialog</name> <message> <location filename

This expression cannot be assigned to

(parse)


[error] 7-7: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 7-7: Expected an expression but instead found '>'.

Expected an expression here.

(parse)


[error] 8-8: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 9-9: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 9-9: Expected a type but instead found '/'.

Expected a type here.

(parse)


[error] 9-9: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 10-10: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 12-12: expected > but instead found filename

Remove filename

(parse)

Additional comments not posted (16)
qgis2plugx.pro (1)

1-7: LGTM!

プロジェクトファイルの変更は問題ありません。ソースファイル、UIファイル、翻訳ファイルが正しく指定されています。

translator/thread.py (1)

58-58: LGTM!

処理中のメッセージを日本語から英語に変更したことで、アプリケーションが両方の言語をサポートするというPRの目的に沿っています。

ui/progress_dialog.py (2)

28-32: LGTM!

UIテキストを英語に変更したことで、アプリケーションの国際化が向上しています。これらの変更により、インターフェースを異なる言語に容易に適応させることができます。

Also applies to: 43-51


65-74: LGTM!

新しいtranslateメソッドは、辞書を使用してメッセージの翻訳を容易にします。これは翻訳を処理するための良いアプローチです。

qgis2plugx.py (3)

5-5: LGTM!

インポート文は正しく、ローカライゼーションの変更に必要です。


29-38: LGTM!

このコードセグメントは正しく実装されており、アプリケーションが翻訳ファイルで定義された翻訳を使用できるようにします。


39-40: LGTM!

tr メソッドは正しく実装されており、現在のロケールに基づいて文字列の動的な翻訳を可能にします。

i18n/QGIS2PlugX_en.ts (1)

1-142: LGTM!

このファイルは、UIの要素とメッセージの英語翻訳を含む新しいXMLファイルです。静的解析ツールからのヒントは誤検知であり、無視できます。ファイルの追加を承認します。

Tools
Biome

[error] 1-1: Expected a type but instead found '?'.

Expected a type here.

(parse)


[error] 1-1: expected : but instead found version

Remove version

(parse)


[error] 1-1: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 1-1: Expected an expression for the left hand side of the > operator.

This operator requires a left hand side value

(parse)


[error] 2-2: Expected a type but instead found '!'.

Expected a type here.

(parse)


[error] 2-2: expected : but instead found TS

Remove TS

(parse)


[error] 2-2: expected > but instead found version

Remove version

(parse)


[error] 2-2: Invalid assignment to TS><TS version

This expression cannot be assigned to

(parse)


[error] 4-4: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 6-6: expected > but instead found filename

Remove filename

(parse)


[error] 2-6: Invalid assignment to "2.0"> <context> <name>Dialog</name> <message> <location filename

This expression cannot be assigned to

(parse)


[error] 6-6: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 6-6: Expected an expression but instead found '>'.

Expected an expression here.

(parse)


[error] 7-7: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 8-8: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 8-8: Expected a type but instead found '/'.

Expected a type here.

(parse)


[error] 8-8: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 9-9: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 11-11: expected > but instead found filename

Remove filename

(parse)


[error] 8-11: Invalid assignment to "unfinished"></translation> </message> <message> <location filename

This expression cannot be assigned to

(parse)

i18n/QGIS2PlugX_ja.ts (1)

1-143: LGTM!

このファイルは、UIの要素とメッセージの日本語翻訳を含む新しいXMLファイルです。静的解析ツールからのヒントは誤検知であり、無視できます。ファイルの追加を承認します。

Tools
Biome

[error] 1-1: Expected a type but instead found '?'.

Expected a type here.

(parse)


[error] 1-1: expected : but instead found version

Remove version

(parse)


[error] 1-1: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 1-1: Expected an expression for the left hand side of the > operator.

This operator requires a left hand side value

(parse)


[error] 2-2: Expected a type but instead found '!'.

Expected a type here.

(parse)


[error] 2-2: expected : but instead found TS

Remove TS

(parse)


[error] 3-3: expected > but instead found version

Remove version

(parse)


[error] 2-3: Invalid assignment to TS> <TS version

This expression cannot be assigned to

(parse)


[error] 3-3: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 5-5: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 7-7: expected > but instead found filename

Remove filename

(parse)


[error] 3-7: Invalid assignment to "ja"> <context> <name>Dialog</name> <message> <location filename

This expression cannot be assigned to

(parse)


[error] 7-7: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 7-7: Expected an expression but instead found '>'.

Expected an expression here.

(parse)


[error] 8-8: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 9-9: Expected a semicolon or an implicit semicolon after a statement, but found none

An explicit or implicit semicolon is expected here...

...Which is required to end this statement

(parse)


[error] 9-9: Expected a type but instead found '/'.

Expected a type here.

(parse)


[error] 9-9: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 10-10: unterminated regex literal

...but the line ends here

a regex literal starts there...

(parse)


[error] 12-12: expected > but instead found filename

Remove filename

(parse)

ui/main_dialog.py (7)

5-6: LGTM!

変更は承認されました。


44-44: LGTM!

変更は承認されました。


104-106: LGTM!

変更は承認されました。


174-178: LGTM!

変更は承認されました。


180-182: LGTM!

変更は承認されました。


Line range hint 185-199: LGTM!

変更は承認されました。


332-336: LGTM!

変更は承認されました。

@@ -5,6 +5,8 @@
from translator.vector.process import process_vector
from translator.vector.label import generate_label_json

from ui.progress_dialog import ProgressDialog
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

未使用のインポートを削除してください。

from ui.progress_dialog import ProgressDialogは使用されていないようです。コードをクリーンに保つために、未使用のインポートは削除することをお勧めします。

このdiffを適用して未使用のインポートを削除してください:

-from ui.progress_dialog import ProgressDialog
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from ui.progress_dialog import ProgressDialog
Tools
Ruff

8-8: ui.progress_dialog.ProgressDialog imported but unused

Remove unused import: ui.progress_dialog.ProgressDialog

(F401)

GitHub Check: Lint

[failure] 8-8: Ruff (F401)
translator/thread.py:8:32: F401 ui.progress_dialog.ProgressDialog imported but unused

Comment on lines 168 to 172
msg = self.tr("Process completed")
msg += f"\n\n"
msg += self.tr("Output folder")
msg += f":\n{params['output_dir']}"

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ですが、不要な f プレフィックスを削除してください。

変更は承認されました。

ただし、静的解析ツールが指摘しているように、169行目の文字列には不要な f プレフィックスがあります。

以下のdiffを適用して f プレフィックスを削除してください:

-        msg += f"\n\n"
+        msg += "\n\n"
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
msg = self.tr("Process completed")
msg += f"\n\n"
msg += self.tr("Output folder")
msg += f":\n{params['output_dir']}"
msg = self.tr("Process completed")
msg += "\n\n"
msg += self.tr("Output folder")
msg += f":\n{params['output_dir']}"
Tools
Ruff

169-169: f-string without any placeholders

Remove extraneous f prefix

(F541)

GitHub Check: Lint

[failure] 169-169: Ruff (F541)
ui/main_dialog.py:169:16: F541 f-string without any placeholders

Copy link
Contributor

@nbayashi nbayashi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK : )

@nbayashi nbayashi merged commit c3ebd25 into main Sep 13, 2024
3 checks passed
@nbayashi nbayashi deleted the feat/multilanguage branch September 13, 2024 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Button to readme
2 participants