/*______________
| ______ | U I Z E J A V A S C R I P T F R A M E W O R K
| / / | ---------------------------------------------------
| / O / | MODULE : Uize.Test.Uize.Loc.FileFormats.ProjectStrings.Xliff Class
| / / / |
| / / / /| | ONLINE : http://uize.com
| /____/ /__/_| | COPYRIGHT : (c)2014-2016 UIZE
| /___ | LICENSE : Available under MIT License or GNU General Public License
|_______________| http://uize.com/license.html
*/
/* Module Meta Data
type: Test
importance: 1
codeCompleteness: 100
docCompleteness: 100
*/
/*?
Introduction
The =Uize.Test.Uize.Loc.FileFormats.ProjectStrings.Xliff= module defines a suite of unit tests for the =Uize.Loc.FileFormats.ProjectStrings.Xliff= module.
*DEVELOPERS:* `Chris van Rensburg`
*/
Uize.module ({
name:'Uize.Test.Uize.Loc.FileFormats.ProjectStrings.Xliff',
builder:function () {
'use strict';
return Uize.Test.resolve ({
title:'Test for Uize.Loc.FileFormats.ProjectStrings.Xliff Module',
test:[
Uize.Test.requiredModulesTest ('Uize.Loc.FileFormats.ProjectStrings.Xliff'),
Uize.Test.staticMethodsTest ([
['Uize.Loc.FileFormats.ProjectStrings.Xliff.to',[
['An object containing multiple resource strings for a file can be serialized to XLIFF format',
{
sourceLanguage:'en_US',
targetLanguage:'fr_FR',
strings:{
'foo/bar.properties':{
widget1:{
TITLE:'widget 1 title',
DESCRIPTION:'the first widget'
},
widget2:{
TITLE:'widget 2 title',
DESCRIPTION:'the second widget'
}
}
}
},
[
'',
'',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
''
].join ('\n')
],
['An object containing resource strings for multiple files can be serialized to XLIFF format',
{
sourceLanguage:'en_US',
targetLanguage:'fr_FR',
strings:{
'foo/bar.properties':{
widget1:{
TITLE:'widget 1 title',
DESCRIPTION:'the first widget'
}
},
'baz/qux.properties':{
widget2:{
TITLE:'widget 2 title',
DESCRIPTION:'the second widget'
}
}
}
},
[
'',
'',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
''
].join ('\n')
],
['When the resource strings contain substitution tokens and a value is specified for the tokenSplitter option, then the substitution tokens are wrapped in tags when serialized to XLIFF format',
[
{
sourceLanguage:'en_US',
targetLanguage:'fr_FR',
strings:{
'foo/bar.properties':{
STR1:'foo {param} bar',
STR2:'foo {param}',
STR3:'{param} bar',
STR4:'{param}',
STR5:'{param1}{param2}'
}
}
},
{tokenSplitter:/\{[\w\d]+\}/}
],
[
'',
'',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
''
].join ('\n')
],
['When the value true is specified for the seedTarget option, then the value of each tag\'s tag is seeded with the untranslated source value of the resource string',
[
{
sourceLanguage:'en_US',
targetLanguage:'fr_FR',
strings:{
'foo/bar.properties':{
widget1:{
TITLE:'widget 1 title',
DESCRIPTION:'the first widget'
},
widget2:{
TITLE:'widget 2 title',
DESCRIPTION:'the second widget'
}
}
}
},
{seedTarget:true}
],
[
'',
'',
' ',
' ',
' ',
' ',
' widget 1 title',
' ',
' ',
' ',
' the first widget',
' ',
' ',
' ',
' widget 2 title',
' ',
' ',
' ',
' the second widget',
' ',
' ',
' ',
''
].join ('\n')
],
['When an object value is specified for the seedTarget option, then the value of each tag\'s tag is seeded with a corresponding value from the seedTarget object, if present, or the untranslated source value of the resource string',
[
{
sourceLanguage:'en_US',
targetLanguage:'fr_FR',
strings:{
'foo/bar.properties':{
widget1:{
TITLE:'widget 1 title',
DESCRIPTION:'the first widget'
},
widget2:{
TITLE:'widget 2 title',
DESCRIPTION:'the second widget'
}
}
}
},
{
seedTarget:{
'foo/bar.properties':{
widget1:{
TITLE:'titre de widget de 1',
DESCRIPTION:'le premier widget'
}
}
}
}
],
[
'',
'',
' ',
' ',
' ',
' ',
' titre de widget de 1',
' ',
' ',
' ',
' le premier widget',
' ',
' ',
' ',
' widget 2 title',
' ',
' ',
' ',
' the second widget',
' ',
' ',
' ',
''
].join ('\n')
],
['When an object value is specified for the seedTarget option, the value for each tag\'s tag is encoded in the same way as the value for its