dpinol / closure-templates

Automatically exported from code.google.com/p/closure-templates
Apache License 2.0
0 stars 0 forks source link

Facing an issue with xliff and GCT #42

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I am trying to do localization using Xliff and render using GCT,i have the 
following .xlf file 

<xliff version='1.2' xmlns='urn:oasis:names:tc:xliff:document:1.2'>  <file 
original='translate.soy' source-language='en' target-language='fr' 
datatype='plaintext'>
 <body>  
<trans-unit id='Hello'> 
<target>Bonjour</target> 
 </trans-unit>  
</body>  </file>  </xliff>  

And the 'translate.soy' file is ]
{namespace poc} 
 /**  *Testing message translation  *@param pageTitle  */  {template .translate}  <HTML>  <Head>  <title>{$pageTitle}  </title>  </head>  <div>  {msg desc="Hello"}Hello{/msg}  </div>  </html>  {/template} 

And the corresponding GCT java code is 
public static String getOutput() {         
 SoyMsgBundleHandler msgBundleHandler = new SoyMsgBundleHandler(new XliffMsgPlugin());      
    SoyMsgBundle msgBundle = null;         
 try {              
  msgBundle = msgBundleHandler.createFromResource(Thread.currentThread().getContextClassLoader().getResource("spanish.xlf"));

} catch (Exception e){}     
     SoyFileSet sfs = (new SoyFileSet.Builder()).add(Resources.getResource("translate.soy")).build();     
    SoyTofu tofu = sfs.compileToJavaObj();        
 String output = tofu.render(poc.translate, new  SoyMapData(.pageTitle,"Translate Test",msgBundle);        
  System.out.println(output);    
     return output;     }    

I need to pring bonjour in place of hello Please let me know where am i going 
wrong? 

Thanks

Original issue reported on code.google.com by sheetalr...@gmail.com on 19 Sep 2011 at 11:29

GoogleCodeExporter commented 8 years ago
The id='Hello' is incorrect. The id is a long number generated by Soy compiler. 
You need to run the SoyMsgExtractor to generate the xliff file with correct id 
for each message.

Original comment by kai.hu...@gmail.com on 20 Sep 2011 at 12:07