Fixed multiple %s replacements.

This commit is contained in:
Martin Edenhofer 2015-07-26 21:28:49 +02:00
parent b6b9def375
commit 8b0e6c8cee
3 changed files with 34 additions and 10 deletions

View file

@ -171,11 +171,11 @@ class App extends Spine.Controller
# define translation helper
params.T = ( item, args... ) ->
App.i18n.translateContent( item, args )
App.i18n.translateContent( item, args... )
# define translation inline helper
params.Ti = ( item, args... ) ->
App.i18n.translateInline( item, args )
App.i18n.translateInline( item, args... )
# define linkify helper
params.L = ( item ) ->

View file

@ -214,11 +214,11 @@ class _i18nSingleton extends Spine.Module
App.Event.trigger('i18n:language:change')
)
translateInline: ( string, args... ) =>
App.Utils.htmlEscape( @translate( string, args... ) )
translateInline: ( string, args ) =>
App.Utils.htmlEscape( @translate( string, args ) )
translateContent: ( string, args... ) =>
translated = App.Utils.htmlEscape( @translate( string, args... ) )
translateContent: ( string, args ) =>
translated = App.Utils.htmlEscape( @translate( string, args ) )
# replace = '<span class="translation" contenteditable="true" data-text="' + App.Utils.htmlEscape(string) + '">' + translated + '<span class="icon-edit"></span>'
if App.Config.get( 'translation_inline' )
replace = '<span class="translation" contenteditable="true" data-text="' + App.Utils.htmlEscape(string) + '">' + translated + ''
@ -228,10 +228,10 @@ class _i18nSingleton extends Spine.Module
else
translated
translatePlain: ( string, args... ) =>
@translate( string, args... )
translatePlain: ( string, args ) =>
@translate( string, args )
translate: ( string, args... ) =>
translate: ( string, args ) =>
# type convertation
if typeof string isnt 'string'

View file

@ -262,6 +262,18 @@ test( "i18n", function() {
var translated = App.i18n.translateContent('yes');
equal( translated, 'ja', 'de-de - yes / ja translated correctly' );
translated = App.i18n.translatePlain('yes');
equal( translated, 'ja', 'de-de - yes / ja translated correctly' );
translated = App.i18n.translateInline('yes');
equal( translated, 'ja', 'de-de - yes / ja translated correctly' );
translated = App.i18n.translateContent('%s ago', 123);
equal( translated, 'vor 123', 'de-de - %s' );
translated = App.i18n.translateContent('%s %s test', 123, 'xxx');
equal( translated, '123 xxx test', 'de-de - %s %s' );
translated = App.i18n.translateContent('<test&now>//*äöüß');
equal( translated, '&lt;test&amp;now&gt;//*äöüß', 'de - <test&now>//*äöüß' );
@ -275,6 +287,18 @@ test( "i18n", function() {
translated = App.i18n.translateContent('yes');
equal( translated, 'yes', 'en-us - yes translated correctly' );
translated = App.i18n.translatePlain('yes');
equal( translated, 'yes', 'en-us - yes translated correctly' );
translated = App.i18n.translateInline('yes');
equal( translated, 'yes', 'en-us - yes translated correctly' );
translated = App.i18n.translateContent('%s ago', 123);
equal( translated, '123 ago', 'en-us - %s' );
translated = App.i18n.translateContent('%s %s test', 123, 'xxx');
equal( translated, '123 xxx test', 'en-us - %s %s' );
translated = App.i18n.translateContent('<test&now>');
equal( translated, '&lt;test&amp;now&gt;', 'en-us - <test&now>' );