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

[Question] Any official way to add new gettext functions? #174

Open
OwenMelbz opened this issue Mar 17, 2018 · 2 comments
Open

[Question] Any official way to add new gettext functions? #174

OwenMelbz opened this issue Mar 17, 2018 · 2 comments

Comments

@OwenMelbz
Copy link

OwenMelbz commented Mar 17, 2018

Hi,

We're in the process of translating a prebuilt wordpress site that uses _e to echo translations.

Currently we're using your extractor, by pushing a custom function to the extractor config using

Gettext\Extractors\PhpCode::$options['functions']['_e'] = 'gettext';

Is there an official method/api to do this? Or would this be considered as acceptable?

Thanks

@oscarotero
Copy link
Member

Hi.
This is the only way in version v3.x
In v4 you can pass the options as an argument:

$translations = Translations::fromPhpCodeFile('my-file.php', [
    'functions' => [
        '_e' => 'gettext'
    ]
]);

@swissspidy
Copy link
Contributor

@OwenMelbz You might be also interested in https://github.com/wp-cli/i18n-command and how we did that there.

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

3 participants