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

Save function and load_script_textdomain depends on editing admin user language #22983

Open
dorkster100 opened this issue Jun 7, 2020 · 2 comments
Labels
[Feature] Blocks Overall functionality of blocks Internationalization (i18n) Issues or PRs related to internationalization efforts [Type] Enhancement A suggestion for improvement.

Comments

@dorkster100
Copy link

Let's say i have a German website, But my admin user is an English speaking person, if his account is not german, then the script language JSON that is loaded is in English. So the save() function of the gutenberg block will translate strings in English and save them to DB.

Should i not be able to do this in the custom block?

save: ( props ) => { return ( <div> <h2>{ __('Open', 'dummy-domain') }</h2> </div> ); },

Expected behavior
Display in admin area strings in admin language but save those strings in website language.

I sadly tested this only on WP 5.3.3, but i checked the i10n.php of the 5.4.1 and it seems the same. Sorry if this is already fixed.

@gziolo gziolo added [Package] i18n /packages/i18n [Feature] Block Validation/Deprecation Handling block validation to determine accuracy and deprecation [Feature] Blocks Overall functionality of blocks Internationalization (i18n) Issues or PRs related to internationalization efforts and removed [Feature] Block Validation/Deprecation Handling block validation to determine accuracy and deprecation [Package] i18n /packages/i18n labels Jul 3, 2020
@gziolo
Copy link
Member

gziolo commented Jul 3, 2020

I was exploring how this type of use case could eorj in #23268. No success so far though.

@dorkster100
Copy link
Author

dorkster100 commented Jul 3, 2020

With server-side rendering it could certainly work, however for now to me this seems like a bug and, the function that load_script_textdomain uses to determine_locale should not have these checks:

if ( is_admin() ) {
	$determined_locale = get_user_locale();
}

if ( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() ) {
	$determined_locale = get_user_locale();
}

Maybe it would be better to use get_locale instead? It would of course be better to be able to see in user's language but save in the website's, but i would consider this as a feature and improvement?

@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks Internationalization (i18n) Issues or PRs related to internationalization efforts [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants