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

Option for custom id transforms. #90

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

Conversation

sullivanpt
Copy link

A custom id mapping can be provided. Examples:
// do not trim the whitespace from the string ends (the current default)
'idTransform': fn(s) { return s; }
// apply html whitespace trimming rules
'idTransform': fn(s) { return s.replace(/\s+/g,' '); }

I am also submitting a matching pull request for rubenv/angular-gettext
References rubenv/grunt-angular-gettext#1, rubenv/angular-gettext#183

A custom id mapping can be provided. Examples:
// do not trim the whitespace from the string ends (the current default)
 'idTransform': fn(s) { return s; }
// apply html whitespace trimming rules
 'idTransform': fn(s) { return s.replace(/\s+/g,' '); }
Copy link

@startusin startusin left a comment

Choose a reason for hiding this comment

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

👍 Is it possible to merge it? Please

@rubenv
Copy link
Owner

rubenv commented Apr 18, 2018 via email

@sullivanpt
Copy link
Author

Wow, this is so long ago I forgot I made this PR. In my case we have multi-line HTML content processed on Windows and Mac developer PCs, so the intermediate whitespace (between lines) can sometimes be line feed, and sometimes be line feed + carriage return, and this makes the exact string white-space matching fail on one host or the other depending on which host was used for the extraction step. In addition to that major annoyance, it's also a little bit confusing for the translators to see all the extra white space between words in the PO file; remember when the browser renders it removes all the extra whitespace. This option gives us the ability to make keys that are platform independent and that look more like the browser actually renders them.

The provided test case in this commit illustrates the problem pretty succinctly.

For the record, we've been avoiding the issue a different way in our code altogether by never having any HTML text with an embedded line break; yes, we have REALLY long lines :-).

Anyway, it would be great if you merge this, but it's not essential. And also, thanks for the amazing library. I've loved using it these past few years.

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

Successfully merging this pull request may close these issues.

3 participants