Hitachi Vantara Pentaho Community Forums
Results 1 to 10 of 10

Thread: Passing Locale variable to XAction file...

  1. #1

    Default Passing Locale variable to XAction file...

    Hi All,

    I am using Pentaho 1.7.0 Reporting server, I am creating reports using Reporting designer, I want to implement Internationalization in my reports, i want to pass locale variable from my application to myReport.xaction file. Can any one tell me what is tag to set locale in XAction file?

    Thanks,
    Prabhakar.

  2. #2

    Default

    I fought with this for a long time before finally getting it to work. I pass in the locale (en_US or es_MX) in s_localeCode and then use a javascript action with the following:

    function setReportLocale() {
    Packages.org.pentaho.messages.util.LocaleHelper.setLocale(new java.util.Locale(s_localeCode));
    }
    setReportLocale();

  3. #3

    Default

    Can u pls attach your XAction file for reference?

    Thanks in advance,
    Prabhakar.

  4. #4

    Default

    Here is some additional information:

    In our situation we have users who need to see reports in multiple languages. We built our reports based on the Pentaho localization documentation. Each report uses Resource Labels and Resource Messages for any text that needs translations. We then set up the property files with the translations for the Resource Labels and Resource Messages using the correct name convention (eg ReportName_en_US.properties and ReportName_es_MX.properties).

    We then set our xactions to take a locale code as an input parameter and then use that parameter to set the language for the report. For example, we set the locale code input parameter to es_MX for the report to show in Spanish.

    Attached is a sample xaction file.
    Attached Files Attached Files

  5. #5

    Default

    Thanks you very much for your response....

    We have changes our XAction file as you said and we have edited our reportname.xml file like the following...

    <element type="text/plain">
    <style>
    <basic-key name="border-top-width">0.0</basic-key>
    <basic-key name="border-top-style">none</basic-key>
    ......
    .......
    </style>
    <template references="resource-label">
    <basic-object name="content">report.gryphonApp</basic-object>
    <basic-object name="nullValue">No Key</basic-object>
    <basic-object name="resourceIdentifier">reportname</basic-object>
    </template>

    </element>

    and, in reportname.peoperties file, we have key in the name of report.gryphonApp and proper value. Here we could not read the key value from properties file.

    Can you please advise.....

    Thanks,
    Prabhakar.

  6. #6

    Default

    Also, do we need to do any other configuration in XML or XAction files, Pls advice....

  7. #7

    Default Still having issue...

    We are also have the same requirement as like you,

    As you said we changed our XAction file like you said....

    <action-definition>
    <component-name>JavascriptRule</component-name>
    <action-type>Set Locale</action-type>
    <action-inputs>
    <s_localeCode type="string"/>
    </action-inputs>
    <action-outputs>
    <s_js_Output type="string"/>
    </action-outputs>
    <component-definition>
    <script><![CDATA[function setReportLocale() {
    Packages.org.pentaho.messages.util.LocaleHelper.setLocale(new java.util.Locale(s_localeCode));
    }
    setReportLocale();]]></script>
    </component-definition>
    </action-definition>

    And we are paasing locale dynamically for 's_localeCode' varible as en_US or fr_FR. And in our XML file we have code like this...

    <element name="ResourceLabel@27479952" type="text/plain">
    <style>
    <basic-key name="border-top-width">1.0</basic-key>
    <basic-key name="border-top-style">none</basic-key>
    ---------
    ---------
    </style>
    <template references="resource-label">
    <basic-object name="content">title</basic-object>
    <basic-object name="nullValue"></basic-object>
    <basic-object name="resourceIdentifier">AgentReport</basic-object>
    </template>
    </element>

    And we have XML file in the name of AgentReport_en_US.properties and AgentReport_fr_FR.properties and we have content in that proties file is title=AGENT REPORT FRENCH and title=AGENT REPORT ENGLISH NEW in both the files...

    But still we cant read values from properties file.

    Herewith I am attaching XAction file, XMl file and properties files for your reference... Please help me out to solve this....

    Thanks,
    Prabhakar.
    Attached Files Attached Files

  8. #8

    Default

    Thanks... We have solved the issue.. and it is working fine now.

    Thanks,
    Prabhakar.

  9. #9
    Join Date
    Mar 2008
    Posts
    18

    Default

    I think for 2.0 the key line of code might need to be

    Packages.org.pentaho.platform.util.messages.LocaleHelper.setLocale(new java.util.Locale(pLanguage, pCountry));

    (package name change)

  10. #10

    Default

    I'm currently having problems with i18n in my reports. I'm using Pentaho Report Designer 3.8 along with Design Studio. I can't seem to set the locale using a Javascript process action with the code snippet that was posted. Is there any way to set the locale based on an input parameter without any code involved?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.