データベースからカスタマイズされたテキストをYMLにエクスポート

Admin interface allows overwriting any stranslations which is very healful not just for utilizing community translation while updating them with custom phrases that suit a specific community, but at the same time it is also a very good way to gradually translate a new language, without the need of updating the code, hence rebuilding the cache. However, it would be great if the customized translations can be exported from the database and somehoe merged back into the corresponding YAML files to make it available in the main repository. Is there a way of doing that which I am not aware of?

「いいね!」 3

I don’t think there is a job for this but 100% support these two tasks, which could help you out here

rake export:locale_overrides:server > server.xx.yml
rake export:locale_overrides:client > client.xx.yml
「いいね!」 7

これまでに誰かがこれを作ったことを知っている人はいますか?

@sam ローカルのエクスポートタスクを実行しましたが、機能しませんでした。
以下のようなメッセージが表示されます。

Don't know how to build task 'export:locale_overrides:server' (See the list of available tasks with `rake --tasks`)

何か考えはありますか?

まだ誰もタスクを作成していません。明確にするために pr-welcome を追加します。

「いいね!」 2

私もこのことについて考えており、PRを作成しました。

「いいね!」 3

ここで話を締めくくるために、@mqmenchacaさんと私は、お互いが作業していることを知らずに、ほぼ同時にこの作業に取り組みました。そして、わずか数時間違いでプルリクエストを作成しました!マックスさんのプルリクエストを見る直前に、私のプルリクエストはすでにコアにマージされていたため、残念ながら彼の作業をコアにマージすることはできません。それでも、貢献には大変感謝しています、@mqmenchacaさん

この機能を追加したコミットはこちらです:DEV: Add a rake task to export/import translation overrides (#18487) · discourse/discourse@4d80110 · GitHub

エクスポートするには、bin/rake export:translation_overrides を実行します(これにより、オーバーライドを含むJSONファイルが作成されます)。

別のインスタンスにインポートするには、エクスポートされたJSONファイルをそこにコピーし、bin/rake import:file["filename"] を実行します。

「いいね!」 4

実行手順を教えていただけますか?

./launcher enter app
bin/rake export:translation_overrides

以下のようなエラーが返されます。

rake aborted!
ActiveRecord::NoDatabaseError: We could not find your database: discourse. Which can be found in the database configuration file located at config/database.yml

それは、お使いの環境の問題のようです。私自身のセルフホストインスタンスでコンテナに入ると、rake コマンドを問題なく実行できます。

「いいね!」 1

DiscourseをNginxの背後で使用しています。それが関連している可能性がありますか?コンテナ外のデータベースを使用してコマンドを実行することは可能ですか?

OK、テストを実行し、ファイルをエクスポートしました。

もし私がそのファイルを変更し、「es_XX」を「es」に変更(それ以外は何も変更せず、ファイルのフォーマットと文字エンコーディングに注意する)して、以前エクスポートしたファイルをインポートしたら、うまくいくはずですか?

以前のオーバーライドを、インスタンスのデフォルトの「es」言語に移動したいのです :slight_smile: