i18n Resource contents does not change dynamically according to browser's language preferences

I installed Japanese translations on OpenClinica 3.4.

Under that environment, some of the internationalized resources are always used even when I changed my browser's preferences to "English".
In details, almost all messages will change according to browser's preferences. For example, messages on pages/studymodule changes in perfect way.
But some of strings does not change. For example, on UpdateStudyNew page (editing study description and status), selection options of Study Phase, Purpose, Selection, and Timing fields are always displayed in Japanese, even when browser's preferences is English.

I viewed some of source codes, then wondering some handling of "resadmin" resource bundle might have some bugs. 
Does anyone have same problem and possible solutions?

Tagged:

Comments

  • mokadamokada Posts: 10
    I attached example from UpdateStudyNew page.
    Contents of select box are displayed in Japanese, even though browser's preference language is English.
    in updateStudy4.jsp, JSP code is below. ${resadmin} should be initialized according to browser's preferences, but it seems not.

       <c:forEach var="purpose" items="${obserPurposeMap}">
       <c:set var="purposekey">
       <fmt:message key="${purpose.key}" bundle="${resadmin}"/>
       </c:set>

           <c:choose>
            <c:when test="${purpose1 == purposekey}">
             <option value="<c:out value="${purpose.key}"/>" selected><c:out value="${purpose.value}"/>
            </c:when>
            <c:otherwise>
             <option value="<c:out value="${purpose.key}"/>"><c:out value="${purpose.value}"/>
            </c:otherwise>
           </c:choose>
        </c:forEach>

  • hhonshukuhhonshuku Posts: 50
    Hi Mokada-san,

    I am not having this problem.  As a habit, I set FireFox cashing to 0MB.  What happen if you manually clear the browser cache?

    I think OpenClinica doesn't expect user to switch local often.  Nevertheless, if you have a solution, your source code contribution would be appreciated.

    Best regards.
  • mokadamokada Posts: 10
    via Email
    こんばんは、hhonshuku さん

    (I assume you can read Japanese, if not, please notify me)

    おそらく日本語で大丈夫だろうと思いまして日本語でメールさせていただきます。
    筑波大学次世代医療研究開発・教育統合センターというところで臨床研究のためのデータセンターを運営しております岡田と申します。
    OpenClinicaには以前から注目していましたが、自分のところでもCDISCの導入を機にOpenClinicaも導入していこうと考えインストールしてみたところです。transfelixのメッセージ翻訳のほうも本日すでにいくつか修正提案を投稿させていただいていますが、できるだけcontributeしていきたいと思っておりますので、よろしくお願い致します。

    問題のスタディ詳細編集画面でのPurposeやPhaseが英語設定のブラウザでも日本語で出てしまう件ですが、FirefoxでもChromeでも、キャッシュをクリアしても、別のマシンからアクセスしても出現するのでブラウザー側の問題ではないような感じです。
    他のリソースはきちんと動的に変化するんですが、admin.properties のリソースのみおかしな感じがするので、もう少しソースを追ってみようかと思います。あと、Observational Studyの場合のPurposeの一覧とか、ほとんどClinicalTrials.gov準拠になっていない状況のところもあるので、そのあたりも修正したいなぁと思っています。とりあえずEclipse+m2e+EGitの環境でソースをいじれるところまでは準備したので、パッチを作ってpull request を発行していくつもりです。

    Masafumi OKADA 岡田 昌史 M.D., Ph.D.
    筑波大学人間総合科学研究科 疫学教室
    筑波大学次世代医療研究開発・教育統合センター
    University of Tsukuba, Dept. of Epidemiology
    E-Mail: mokada@md.tsukuba.ac.jp


    On 2014年10月20日 at 23:19:30, hhonshuku (forums+d15461@openclinica.org) wrote:

    Hi Mokada-san,


    I am not having this problem.  As a habit, I set FireFox cashing to 0MB.  What happen if you manually clear the browser cache?




    I think OpenClinica doesn't expect user to switch local often.  Nevertheless, if you have a solution, your source code contribution would be appreciated.




    Best regards.
  • hhonshukuhhonshuku Posts: 50
    Okada-san,
    Thank you for your update.  Yes, I can read/write Japanese, while it will be more beneficial to others in English.  If you'd like, I welcome personal messages in Japanese.

    I have not been able to reproduce your issue on my end.  I am on Mac OSX10.9.5 and FireFox v30.  Please let me know your environment so I can try to reproduce it.

    Best regards.

    -Hiro(本宿宏明)
  • mokadamokada Posts: 10
    I'm sorry that I misunderstood that my previous message was personal message. 
    I will continue conversation with English.

    My environment is Ubuntu 12.04.5 LTS running Tomcat 6.0.35. 
    System locale is ja_JP.UTF-8.
    Maybe older tomcat version cause the problem. I will try to reproduce the problem within Ubuntu 14 virtual machine.


  • hhonshukuhhonshuku Posts: 50
    Dear Okada-san,

    I was able to reproduce the issue.  Thank you for reporting.
  • mokadamokada Posts: 10
    hhonsyuku-san,

    I found there are two problems around internationalized resources.

    First, depending on operating system's locale and java implementation, original English resource files cannot be read by openclinica instance. To avoid this issue, renaming original resource files are required.

    Second, when updating browser's language preferences dynamically, JSP components follows locale changes, but Servlet components will not follow changes. To fix this issue, a patch on source code will be required ( I'm testing that now ).

    Details of the first problem:

    When openclinica runs in Ubuntu 12.0.4 , running OpenJDK  6b33-1.13.5-1ubuntu0.12.04, in ja_JP.UTF-8 locale, getBundle(name,locale) method of java.util.ResouceBundle class seeks resources for given locale. But if resource file for specified locale cannot be found, it obtains resource file for "default locale". 
    In Japanese OS locale, the "default locale" is Japanese. So once I copied Openclinica's Japanese localized resource files (i.e. admin_ja.properties, words_ja.properties....) on WEB-INF/classes/org/akaza/openclinica/i18n/, only Japanese resource files are read. Original resource files are ignored because it (admin.properties, words.properties...) has no locale suffix in its filename.

    To avoid this, I renamed original resource files to have "_en" suffix.(i.e. admin_en.properties, words_en.properties...) 
    This fixed my problem partially. Within one tomcat session, English study purposes or selections are correctly displayed. 

    But still study purposes or selections does not follow browser's language preferences.
    I think that is because lack of codes which updates resource contents in servlet components. I am trying a patch for UpdateStudyNew.java and CreateStudyServlet.java. When I will succeed to solve the problem I'll post follow-up.


  • mokadamokada Posts: 10
    Here is a patch to update servlets' internationalized resources, every time when servlet is called.

    Current OpenClinica 3.4 sourcetree does not update key-value map, which is used to make selection boxes in UpdateStudyNew servlet. Updating function is found in CreateStudyServlet.java, but it was non-static private function. So this patch makes almost same function as public static function, and call it from UpdateStudy and UpdateStudyNew servlet class.

    With this patch, every time when I changed browser's language preferences and reload openclinica pages, language changes dynamically, including choices in select boxes.


  • rpetrusevschirpetrusevschi Posts: 24 admin
    Hi Okada-san,

    Thank you for your patch. We'll have our team look at it. We will soon have our i18n/L10n files available on GitHub to make such submissions easier. 

    All the best,
    Rodica
  • hhonshukuhhonshuku Posts: 50
    Okada-san,
    Thank you for your pull request.  I pushed it to our product manager.  Stay tuned!
This discussion has been closed.