Skip to content

Support custom function names #93

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

Open
ArmorDarks opened this issue Jun 18, 2015 · 7 comments
Open

Support custom function names #93

ArmorDarks opened this issue Jun 18, 2015 · 7 comments

Comments

@ArmorDarks
Copy link

Some projects uses another gettext function names, like, _t() for singular forms and _pt() for plurals, etc.

Is there any chances to see ability pass to jsxgettext object which will map custom function names to gettext(), ngettext() and so on?

grunt-xgettext partially implemented that feature, maybe something can be learned from it. Besides, there were issue about even further expending of that feature: https://github.com/arendjr/grunt-xgettext/issues/8

@BYK
Copy link
Collaborator

BYK commented Jun 18, 2015

Haha, this is what I feared when we hard-coded the n prefix. I believe this is doable, just requires some more effort.

I'll try to get to this soon.

@BYK
Copy link
Collaborator

BYK commented Jun 18, 2015

//cc @vrouet

@BYK BYK changed the title Support custom function names Support custom function names for ngettext Jun 18, 2015
@ArmorDarks
Copy link
Author

Thanks a lot! :)

Well, in fact some libraries even use another position of arguments. Some going even further and providing chaining (like Jed).

But I guess ability to remap arguments, or define somehow completely custom function would be too hard task. grunt-xgettext tried to implement it, but, unfortunately, they didn't advance much further than just discussion.

@BYK
Copy link
Collaborator

BYK commented Jun 18, 2015

Well, in fact some libraries even use another position of arguments. Some going even further and providing chaining (like Jed).

I think the promise of jsxgettext is to support GNU gettext interface as closely as possible. Anything non-standard should not make it into the core package. I even hate the custom template parsers but that needs a larger refactor.

@ArmorDarks
Copy link
Author

I think the promise of jsxgettext is to support GNU gettext interface as closely as possible. Anything non-standard should not make it into the core package.

yeah, I completely agree

@ArmorDarks
Copy link
Author

Maybe we can support it with regex?

Users which would need only basic functionality could map each function to custom name just with object and strings inside, but if someone will need something custom — regex to the rescue with named regex groups.

For sure we won't provide ready regex for non-trivial systems, like Jed, out of box.

For simpler cases we can also map arguments based on user's input. Here are some thought about it: https://github.com/arendjr/grunt-xgettext/issues/8

@ArmorDarks ArmorDarks changed the title Support custom function names for ngettext Support custom function names Oct 16, 2015
@ArmorDarks
Copy link
Author

For the informations: native xgettext provides quite flexible way to set custom functions names and map arguments: http://poedit.net/trac/wiki/Doc/Keywords

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

No branches or pull requests

2 participants