TMX and templates in 6.5.2

The instructions for internationalizating a template tell you to update the ResourceBundle.tmx file. That’s all they tell you to do. They don’t even say to restart. Is that really all you have to do to translate static text in a template? I’m surprised that you don’t have to do anything in the actual template (aside from set the $locale variable in the binding).

Anyway, I tried it (although, I did restart), and I am not seeing any results. Any tips on what else I can try? Here is what I did:

  1. Updated the rxconfig/I18N/ResourceBundle.tmx file with this:
<tu tuid="velocity.cnProductIndex_GlobalTemplate@All">
         <prop type="sectionname" xml:lang="en-us">XSL Stylesheet</prop>
         <note xml:lang="en-us">The label for a link to all items</note>
         <tuv xml:lang="en-us">
            <seg>All</seg>
         </tuv>
	<tuv xml:lang="ja-jp">
            <seg>All in Japanese</seg>
         </tuv>
      </tu>
  1. Set the $locale = $sys.item.getProperty(“sys_lang”) in the bindings.
  2. Restarted the server.
  3. Changed to the Japanese domain and previewed a Japanese translation of an item, with a template that uses the above global template.

Still just seeing ‘All’. Which doesn’t surprise me so much. It seems like I must be missing a step.


Add this to your template:

$rx.i18n.getString("All", $sys.item.getProperty("rx:sys_lang").String)

It should render in both English and Japanese items. You can use $locale if your bindings already contain it. Don’t forget the .String.

Dave

Ah. I knew there must be something like that.

Thanks!

Doh! It didn’t work. I pasted your code into my template, and it’s still not translated. Do any of my steps look wrong?

Is there any way to debug this?

Thanks.

I tried this to see what would happen. It’s still showing the English version:
$rx.i18n.getString(“All”, “ja-jp”)

Probably something to do with the “namespace” of the “All” keyword. I don’t know what it should be off the top of my head: some more research will be required.

I tried changing my string to ‘Betty’. Still doesn’t work.

I would not have expected it to :slight_smile:

In the TMX file, you have defined the key as “velocity.cnProductIndex_GlobalTemplate@All”

I’m not sure whether this is the correct prefix, and if it is, how much of it needs to be specified in the JEXL expression… I’ll have to run some tests and look further into the code/documentation of these methods.

[QUOTE=dbenua;6197]I would not have expected it to :slight_smile:

In the TMX file, you have defined the key as “velocity.cnProductIndex_GlobalTemplate@All”

I’m not sure whether this is the correct prefix, and if it is, how much of it needs to be specified in the JEXL expression… I’ll have to run some tests and look further into the code/documentation of these methods.[/QUOTE]
Thanks for looking into it.

I should have been more clear: I tried this:

<tu tuid="velocity.cnProductIndex_GlobalTemplate@Betty">
         <prop type="sectionname" xml:lang="en-us">XSL Stylesheet</prop>
         <note xml:lang="en-us">The label for a link to all items</note>
         <tuv xml:lang="en-us">
            <seg>Betty</seg>
         </tuv>
	<tuv xml:lang="ja-jp">
            <seg>Betty in Japanese</seg>
         </tuv>
   </tu>

to see if the problem was the word ‘All’


Dave was on the right track. You need to provide the entire key in the $rx.i18n.getString method: e.g. $rx.i18n.getString(“velocity.cnProductIndex_GlobalTemplate@Betty”, “ja-jp”)

You don’t have to restart to pick up changes in the tmx file, you just have to use the “reload i18nresources” console command.

Actually, your last suggestion worked. I had another, unrelated issue that was effecting it.

I recently moved my rhythmyx root to another disk. I simply copied it over there. And that seemed to work fine. But it is still using the rxconfig files that are in the original location. So I needed to update the ResourceBundle.tmx file over there.

P.S. I went back to using the original root. It’s just for development on my own desktop, but obviously I was risking some problems by moving my root directory.

Does this work if the keys (static text) is inside macro in an assembly file. I tried everything but it doesnt seem to work for me.

I have a snippet template rfh_Sn_TitleAuthorDateLink which calls the macro rfh_posted_on which takes locale as the parameter. The macro is in rfh_assembly.vm file. So this is what I have


<tu tuid="velocity.rfh_assembly@By">
        <prop type="sectionname" xml:lang="en-us">XSL Stylesheet</prop>
         <note xml:lang="en-us">The label for  Author name</note>
         <tuv xml:lang="en-us">
            <seg>By</seg>
         </tuv>
	   <tuv xml:lang="fr-ca">
            <seg>Par</seg>
         </tuv>
      </tu>

Here is the macro


#macro(rfh_by_posted_on $sys_lang)
	
		<p>	$rx.i18n.getString("velocity.rfh_assembly@By", $sys_lang): #multiline('authors')
	
#end

It always displays ‘By’ even when $sys_lang = “fr-ca”

What am I missing here? I tried to change the namespace from velocity.rfh_assembly@By to rfh_Sn_TitleAuthorDateLink@By but nothing works

Pallavi

Ok I was able to get that to work.

Pallavi,

Would you share your solution here? Then others can learn from it.

Thanks!

RLJII

I believe I just restarted the server again to get it to work.

Pallavi