プロジェクト

全般

プロフィール

Bug(バグ) #1894

The translation is wrong when there are same string to files of the translation (複数の翻訳ファイルに同一の文言が存在した場合、間違った翻訳がされる)

Masato Nagasawa約13年前に追加. 8年以上前に更新.

ステータス:
Fixed(完了)
優先度:
High(高め)
担当者:
対象バージョン:
開始日:
2011-01-26
期日:
進捗率:

100%

3.6 で発生するか:
Yes
3.8 で発生するか:
Unknown (未調査)

説明

Overview (現象)

再現手順

1. キャッシュをクリアする

symfony cc

2. トピック作成の項目「タイトル」と表示されている事を確認

http://exmaple.com/communityTopic/new/1

3. 再度トピック作成を表示すると「タイトル」が「名前」になっている

Causes (原因)

フォームの翻訳時に、他の箇所で読み込んだ翻訳ファイルのリストがクリアされていないことが原因。

現象例で示したトピック作成で「タイトル」が「名前」となる原因は、
アプリケーション登録ページで同一の文言「Name」を定義しているためである。

http://exmaple.com/connection/new

また、一度目に「タイトル」と正常に表示されたのは、
「symfony cc」した時点でキャッシュが作成されておらず、
この時「sfMessageSource_OpenPNECache」クラスではなく「sfMessageSource_OpenPNE」クラスが使用されたためである。

Way to fix (修正内容)

sfMessageSource_OpenPNECached::load() の呼び出し時に、
$this->messages に読み込んだ翻訳ファイルの内容をクリアしていないことが原因。

継承元の sfMessageSource::load() では以下のように初期化している。

lib/vendor/symfony/lib/i18n/sfMessageSource.class.php

157   function load($catalogue = 'messages')
158   {
159     $variants = $this->getCatalogueList($catalogue);
160 
161     $this->messages = array();
162

しかしこのままの実装でこの修正を行うと、
include() で毎回翻訳ファイルが読み込まれる問題があるため、
翻訳ファイルの内容をキャッシュする実装にするべきである。

sfMessageSource::load() では読み込んだ内容をキャッシュする機構がすでに備わっており、
そもそも sfMessageSource::load() をオーバーライドするのではなく、
sfMessageSource::load() 内で呼ばれるメソッドをオーバーライドして実装するべきではないか。

下記のような実装で修正したところ、正常な挙動となった。

   public function getCatalogueList($catalogue)
   {
     $variants = explode('_', $this->culture);
-    $base = $this->source.DIRECTORY_SEPARATOR.$catalogue.$this->dataSeparator;
+    $base = $catalogue.$this->dataSeparator;

     return array(
       $base.$variants[0].$this->dataExt, $base.$this->culture.$this->dataExt,
     );
   }

-  public function load($catalogue = 'messages')
-  {
-    $variants = $this->getCatalogueList($catalogue);
-
-    foreach ($variants as $variant)
-    {
-      if (isset($this->messages[$variant]))
-      {
-        return true;
-      }
-
-      if (is_file($variant))
-      {
-        $this->messages[$variant] = include($variant);
-
-        return true;
-      }
-    }
-
-    return true;
-  }
-
   public function save($catalogue = 'messages')
   {
     return true;
@@ -65,4 +44,9 @@ class sfMessageSource_OpenPNECached extends sfMessageSource_File
   {
     return true;
   }
+
+  public function &loadData($variant)
+  {
+    return include($variant);
+  }
 }

この修正によって、今まで翻訳されていた箇所が翻訳されなくなる部分があります。
これは今までの挙動が間違っていただけであり、適切な翻訳を追加して対応する必要があります。

今回の修正よって、独自のカテゴリを指定している箇所で影響が出ます。
確認した限り以下の箇所が翻訳されていませんでした。

* communityTopic/new/[id]
* communityEvent/new/[id]

Photo 1 → 写真 1
Photo 2 → 写真 2
Photo 3 → 写真 3


関連するチケット

関連している opCommunityTopicPlugin - Bug(バグ) #1652: トピックを作成時、項目名が「タイトル」ではなく「名前」になっている Invalid(無効) 2010-10-05
関連している OpenPNE 3 - Backport(バックポート) #2194: The translation is wrong when there are same string to files of the translation (複数の翻訳ファイルに同一の文言が存在した場合、間違った翻訳がされる) Fixed(完了) 2011-06-10
関連している OpenPNE 3 - Bug(バグ) #2490: 翻訳ファイルの優先順位がキャッシュ時に逆になっている Fixed(完了) 2011-10-14

関係しているリビジョン

リビジョン ff508991 (差分)
Masato Nagasawa約13年前に追加

fixed translation when loading from the cache file (fixes #1894)

リビジョン 1b9899e3 (差分)
Masato Nagasawa約13年前に追加

fixed notice of the variable references (fixes #1894)

履歴

#1 Masato Nagasawa約13年前に更新

  • 題名複数の翻訳ファイルに同一の文言が存在した場合、間違った翻訳がされる から The translation is wrong when there are same string to files of the translation (複数の翻訳ファイルに同一の文言が存在した場合、間違った翻訳がされる) に変更

#2 Masato Nagasawa約13年前に更新

  • ステータスNew(新規) から Accepted(着手) に変更
  • 担当者Masato Nagasawa にセット

#3 Masato Nagasawa約13年前に更新

  • ステータスAccepted(着手) から Pending Review(レビュー待ち) に変更
  • 進捗率0 から 50 に変更

更新履歴 ff5089916d44e3055e284be0656664fb4a08a7d8 で適用されました。

#4 Masato Nagasawa約13年前に更新

  • ステータスPending Review(レビュー待ち) から Accepted(着手) に変更

参照を返すメソッドでスカラー値を直接返していたため Noticeが出ていました。

function &loadData($variant)

Notice: Only variable references should be returned by reference

読み込んだ内容を一度変数に格納するように修正します。

#5 Masato Nagasawa約13年前に更新

  • ステータスAccepted(着手) から Pending Review(レビュー待ち) に変更

更新履歴 1b9899e3693567e25c41c8a628165dac2a982313 で適用されました。

#6 pnetan  ほぼ13年前に更新

関連情報

公式SNS内にて関連する報告を発見したため、記載します。
『イベントを作成する』際の『名前』 項目を『タイトル』 にしたい→ http://sns.openpne.jp/communityTopic/7106

#7 Kousuke Ebiharaほぼ13年前に更新

この修正によって、今まで翻訳されていた箇所が翻訳されなくなる部分があります。
これは今までの挙動が間違っていただけであり、適切な翻訳を追加して対応する必要があります。

今回の修正よって、独自のカテゴリを指定している箇所で影響が出ます。
確認した限り以下の箇所が翻訳されていませんでした。

への対応(バンドルプラグインも含む)をこのバージョンのリリースの過程でおこなう必要があります。

#8 Shingo Yamada12年以上前に更新

  • 優先度Normal(通常) から High(高め) に変更

#9 Shingo Yamada12年以上前に更新

  • 360対象beta13 にセット

#10 Kousuke Ebihara12年以上前に更新

この修正により未翻訳となるものは、「カタログを指定していながらその翻訳文言がカタログに定義されておらず、他のカタログの定義によって翻訳されていた」ものです。

デフォルトのカタログ以外のカタログを使用しているものは以下の通りです。

form_community カタログを使用している

  • lib/filter/doctrine/CommunityFormFilter.class.php
  • lib/form/doctrine/CommunityCategoryForm.class.php
  • lib/form/doctrine/CommunityConfigForm.class.php
  • lib/form/doctrine/CommunityForm.class.php
  • plugins/opCommunityTopicPlugin/lib/form/doctrine/PluginCommunityTopicSearchForm.class.php
  • apps/pc_frontend/modules/community/templates/homeSuccess.php
  • plugins/opCommunityTopicPlugin/apps/pc_frontend/modules/communityEventComment/templates/_list.php
  • plugins/opCommunityTopicPlugin/apps/pc_frontend/modules/communityTopic/templates/searchSuccess.php
  • plugins/opCommunityTopicPlugin/apps/pc_frontend/modules/communityTopicComment/templates/_list.php
  • apps/mobile_frontend/modules/community/templates/detailSuccess.php
  • apps/mobile_frontend/modules/community/templates/homeSuccess.php
  • plugins/opCommunityTopicPlugin/apps/mobile_frontend/modules/communityEventComment/templates/_list.php
  • plugins/opCommunityTopicPlugin/apps/mobile_frontend/modules/communityTopicComment/templates/_list.php
  • apps/pc_backend/modules/community/templates/_categoryListForm.php
  • apps/pc_backend/modules/community/templates/_communityInfo.php
  • plugins/opCommunityTopicPlugin/apps/pc_backend/modules/communityTopic/lib/CommunityEventCommentSearchForm.class.php
  • plugins/opCommunityTopicPlugin/apps/pc_backend/modules/communityTopic/lib/CommunityEventMemberSearchForm.class.php
  • plugins/opCommunityTopicPlugin/apps/pc_backend/modules/communityTopic/lib/CommunityEventSearchForm.class.php
  • plugins/opCommunityTopicPlugin/apps/pc_backend/modules/communityTopic/lib/CommunityTopicCommentSearchForm.class.php
  • plugins/opCommunityTopicPlugin/apps/pc_backend/modules/communityTopic/lib/CommunityTopicSearchForm.class.php

form_member カタログを使用している

  • lib/form/doctrine/MemberForm.class.php

pager カタログを使用している

  • apps/mobile_frontend/templates/_pagerNavigation.php
  • apps/mobile_frontend/templates/_pagerReversibleNavigation.php
  • apps/mobile_frontend/templates/_pagerTotal.php
  • apps/pc_backend/templates/_pagerNavigation.php
  • apps/pc_backend/templates/_pagerReversibleNavigation.php
  • apps/pc_backend/templates/_pagerTotal.php
  • apps/pc_frontend/templates/_pagerNavigation.php
  • apps/pc_frontend/templates/_pagerReversibleNavigation.php
  • apps/pc_frontend/templates/_pagerTotal.php
  • plugins/opMessagePlugin/apps/pc_frontend/modules/message/templates/showSuccess.php
  • plugins/opOpenSocialPlugin/apps/pc_frontend/modules/application/templates/_inviteList.php

community_event_form カタログを使用している

  • plugins/opCommunityTopicPlugin/apps/mobile_frontend/modules/communityEvent/templates/showSuccess.php
  • plugins/opCommunityTopicPlugin/apps/pc_frontend/modules/communityEvent/templates/showSuccess.php
  • plugins/opCommunityTopicPlugin/lib/form/doctrine/PluginCommunityEventForm.class.php

community_topic_form カタログを使用している

  • plugins/opCommunityTopicPlugin/apps/pc_frontend/modules/communityTopic/templates/searchSuccess.php
  • plugins/opCommunityTopicPlugin/lib/form/doctrine/PluginCommunityTopicForm.class.php

api カタログを使用している

  • lib/form/doctrine/OAuthConsumerInformationForm.class.php
  • lib/util/opToolkit.class.php

profile_exchange カタログを使用している

  • apps/pc_frontend/modules/OpenID/templates/indexTrust.php

publicFlags カタログを使用している

  • lib/model/doctrine/ActivityDataTable.class.php
  • plugins/opDiaryPlugin/lib/model/doctrine/PluginDiaryTable.class.php

#11 Kousuke Ebihara12年以上前に更新

http://redmine.openpne.jp/issues/1894#note-10 のすべてのファイルについて確認をおこないましたが、以下の翻訳の追加の必要があるのみでした。

community_topic_form, community_event_form カタログに追加する必要があると思われる翻訳

  • Photo 1
  • Photo 2
  • Photo 3

今回の影響範囲以外で気になった点

※あまり検証していないので参考程度に

  • plugins/opCommunityTopicPlugin/apps/mobile_frontend/i18n/community_event_form.ja.xml に、 pc_frontend には存在する「The open date must be after now.」と「The application deadline must be before the open date.」の翻訳がない

#12 Kousuke Ebihara12年以上前に更新

  • ステータスPending Review(レビュー待ち) から Pending Testing(テスト待ち) に変更
  • 進捗率50 から 70 に変更

http://redmine.openpne.jp/issues/1894#note-11 の件について、 opCommunityTopicPlugin 側にチケットを作成しました(#2355)。

本チケットの修正としては特に問題は見当たらないため、テスト待ちにします。

#13 Fumie Toyooka12年以上前に更新

  • ステータスPending Testing(テスト待ち) から Fixed(完了) に変更
  • 進捗率70 から 100 に変更

テストOKです。

#14 kaoru n8年以上前に更新

  • 3.8 で発生するかUnknown (未調査) にセット

他の形式にエクスポート: Atom PDF