Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support backslash based escaping for placeholders #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

santhoshtr
Copy link
Member

The simpleParse method of parser, which get invoked if message contains
only placeholders, was not supporting escaped placeholders($10)

The light weight versio of jquery.i18n when parser.js not included
also has the same fix now.

Add support for that and add tests.
Updated the documentation in README.md too

Fixes issue #74

@Nikerabbit
Copy link
Member

Can you rebase this to get rid of the conflict?

@santhoshtr santhoshtr force-pushed the issue74 branch 2 times, most recently from dcc4562 to 827ca13 Compare June 8, 2016 04:28
@@ -142,7 +142,7 @@
source = 'i18n/' + $.i18n().locale + '.json';
locale = $.i18n().locale;
}
if ( typeof source === 'string' &&
if ( typeof source === 'string' &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What changed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange. dont know.

The simpleParse method of parser, which get invoked if message contains
only placeholders, was not supporting escaped placeholders(\\$10)

The light weight versio of jquery.i18n when parser.js not included
also has the same fix now.

Add support for that and add tests.
Updated the documentation in README.md too

Fixes issue wikimedia#74
} );
assert.strictEqual(
$.i18n( 'This message key does not exist' ),
'This message key does not exist',
'This message key does not exist'
);
assert.strictEqual( $.i18n( 'Hello $1', 'Bob' ), 'Hello Bob', 'Parameter replacement' );
assert.strictEqual(
$.i18n( 'Price of {{PLURAL:$1|an item|$1 items}} is $2, you get \\$2 discount', 5, 2000 ),
'Price of 5 items is 2000, you get $2 discount', 'Parameter replacement with dollar sign escaped, not parsed using simplePaser'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The third param should be on its own line.

@winstonsung
Copy link
Contributor

Rebase needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants