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

Use literal 'wp-auth0' rather than WPA0_LANG constant #311

Merged
merged 1 commit into from
Aug 16, 2017

Conversation

idpaterson
Copy link
Contributor

@idpaterson idpaterson commented Apr 17, 2017

Translation tools are generally not able to map a runtime constant like WPA0_LANG to a value for the text domain and therefore most of the text within this plugin was not automatically available for translating. A literal string value for the text domain ensures better compatibility.

This pull request updates all occurrences of WPA0_LANG to the literal 'wp-auth0' and adds the text domain in a few places where it was missing. The literal value uses either single or double quotes for consistency with the adjacent translated text. The WPA0_LANG constant is still defined to avoid backwards compatibility issues for anything that may still use it.

This problem was discovered when working on #308. I attempted to use the popular Loco translation plugin to change the error message text but only a few strings (those with the default text domain) were available for translation. I was able to use * as a wildcard in Loco but then the particular error message that I needed to change was not translatable (see #312).

@cocojoe
Copy link
Member

cocojoe commented Jun 30, 2017

Can you fix conflicts please, also why doesn't a constant work?

@idpaterson
Copy link
Contributor Author

WordPress strongly suggests against it because gettext which parses these files does not interpret PHP. It knows how to pull out a literal text domain but cannot map a variable or constant to the corresponding value, so you end up with an incorrect or missing text domain that inhibits translation.

Thanks for taking a look, I will fix up the conflicts.

@idpaterson idpaterson force-pushed the pull-requests/literal-text-domain branch 2 times, most recently from ef73f2c to 28a4a75 Compare June 30, 2017 15:40
@cocojoe
Copy link
Member

cocojoe commented Jun 30, 2017

Ah good thanks for the reference.

@idpaterson
Copy link
Contributor Author

It seems this once again has conflicts; I'm not inclined to continue fixing conflicts for every minor typo fix that is committed. Please let me know whether this will actually be merged.

@cocojoe
Copy link
Member

cocojoe commented Aug 2, 2017

Sorry about this @glena any feelings against this? seems to be the preferred method.

@cocojoe
Copy link
Member

cocojoe commented Aug 2, 2017

@idpaterson Can you rebase to master and fix conflicts thanks.

@idpaterson
Copy link
Contributor Author

I am happy to rebase and fix the conflicts if this is en route to acceptance but will wait until you've all agreed that this is an acceptable change.

@cocojoe
Copy link
Member

cocojoe commented Aug 9, 2017

This should be fine, please rebase 😄

@idpaterson idpaterson force-pushed the pull-requests/literal-text-domain branch from 28a4a75 to 66d3f95 Compare August 10, 2017 13:55
@idpaterson idpaterson changed the base branch from dev to master August 10, 2017 13:55
@idpaterson
Copy link
Contributor Author

This should be good to go, note that there are both text domains switched from the WPA0_LANG constant and newly added text domains that were previously blank. There are also a few alternate domains (wp_auth0_widget_domain, wpb_widget_domain) that were not modified.

@cocojoe cocojoe self-requested a review August 11, 2017 14:34
Copy link
Member

@cocojoe cocojoe left a comment

Choose a reason for hiding this comment

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

So this looks fine, I was a little hesistant on this however it is the preferred method from the WP docs. Although I am unsure how PHP processes a define vs a variable. @glena any thoughts here?

@cocojoe cocojoe changed the base branch from master to dev August 11, 2017 15:01
@cocojoe cocojoe added this to the v3-Next milestone Aug 11, 2017
@cocojoe
Copy link
Member

cocojoe commented Aug 11, 2017

Oh, sorry @idpaterson can you rebase to dev please, same goes for your other PR Thx. So close 😄

@idpaterson idpaterson force-pushed the pull-requests/literal-text-domain branch from 66d3f95 to fb535e4 Compare August 15, 2017 16:54
@idpaterson
Copy link
Contributor Author

Rebased this and #312 back to dev

Copy link
Member

@cocojoe cocojoe left a comment

Choose a reason for hiding this comment

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

Still think it's odd in some ways. However, is the WP preferred way and you also ran into issues with it so no harm in doing so. Any concerns @glena ? The define is still there in case something somewhere in the shadows references it 😄

@glena
Copy link
Contributor

glena commented Aug 16, 2017

LGTM

@glena glena merged commit 92af277 into auth0:dev Aug 16, 2017
@cocojoe cocojoe modified the milestones: v3-Next, 3.3.2 Oct 5, 2017
@cocojoe cocojoe mentioned this pull request Oct 5, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants