Improved inline markup.

This commit is contained in:
Martin Edenhofer 2016-02-07 21:53:47 +01:00
parent 06e9a6abbe
commit cbbf34c271
2 changed files with 10 additions and 3 deletions

View file

@ -186,7 +186,8 @@ class _i18nSingleton extends Spine.Module
# apply inline markup # apply inline markup
translated translated
.replace(/\*(.+?)\*/gm, '<b>$1</b>') .replace(/\|\|(.+?)\|\|/gm, '<i>$1</i>')
.replace(/\|(.+?)\|/gm, '<b>$1</b>')
.replace(/_(.+?)_/gm, '<u>$1</u>') .replace(/_(.+?)_/gm, '<u>$1</u>')
.replace(/§(.+?)§/gm, '<kbd>$1</kbd>') .replace(/§(.+?)§/gm, '<kbd>$1</kbd>')

View file

@ -274,9 +274,12 @@ test( "i18n", function() {
translated = App.i18n.translateContent('%s %s test', 123, 'xxx'); translated = App.i18n.translateContent('%s %s test', 123, 'xxx');
equal( translated, '123 xxx test', 'de-de - %s %s' ); equal( translated, '123 xxx test', 'de-de - %s %s' );
translated = App.i18n.translateContent('*%s* %s test', 123, 'xxx'); translated = App.i18n.translateContent('|%s| %s test', 123, 'xxx');
equal( translated, '<b>123</b> xxx test', 'de-de - *%s* %s' ); equal( translated, '<b>123</b> xxx test', 'de-de - *%s* %s' );
translated = App.i18n.translateContent('||%s|| %s test', 123, 'xxx');
equal( translated, '<i>123</i> xxx test', 'de-de - *%s* %s' );
translated = App.i18n.translateContent('_%s_ %s test', 123, 'xxx'); translated = App.i18n.translateContent('_%s_ %s test', 123, 'xxx');
equal( translated, '<u>123</u> xxx test', 'de-de - _%s_ %s' ); equal( translated, '<u>123</u> xxx test', 'de-de - _%s_ %s' );
@ -311,9 +314,12 @@ test( "i18n", function() {
translated = App.i18n.translateContent('%s %s test', 123, 'xxx'); translated = App.i18n.translateContent('%s %s test', 123, 'xxx');
equal( translated, '123 xxx test', 'en-us - %s %s' ); equal( translated, '123 xxx test', 'en-us - %s %s' );
translated = App.i18n.translateContent('*%s* %s test', 123, 'xxx'); translated = App.i18n.translateContent('|%s| %s test', 123, 'xxx');
equal( translated, '<b>123</b> xxx test', 'en-us - *%s* %s' ); equal( translated, '<b>123</b> xxx test', 'en-us - *%s* %s' );
translated = App.i18n.translateContent('||%s|| %s test', 123, 'xxx');
equal( translated, '<i>123</i> xxx test', 'en-us - *%s* %s' );
translated = App.i18n.translateContent('_%s_ %s test', 123, 'xxx'); translated = App.i18n.translateContent('_%s_ %s test', 123, 'xxx');
equal( translated, '<u>123</u> xxx test', 'en-us - _%s_ %s' ); equal( translated, '<u>123</u> xxx test', 'en-us - _%s_ %s' );