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

internationalize new header/footer #46

Closed
7 tasks done
iandunn opened this issue Dec 23, 2021 · 8 comments
Closed
7 tasks done

internationalize new header/footer #46

iandunn opened this issue Dec 23, 2021 · 8 comments
Assignees
Labels
[Type] Enhancement New feature or request
Milestone

Comments

@iandunn
Copy link
Member

iandunn commented Dec 23, 2021

it needs to work in other locales. not just on the rosetta sites, but also sites like Learn that have locale switchers, and the homepage (which has an automatic switch

Basic string internationalization

  • Header: global menu items - done in 9a7ed8d for Use Rosetta header menu items instead of global #49
  • Header alt tags, etc
  • Footer
  • sync code to w.org so new strings can be translated
  • sync strings to GlotPress - may need to update the bin script to explicitly process mu-plugins/pub-sync/
  • wait until translated in a few locales
  • test on rosetta sites
@iandunn iandunn added this to the News launch milestone Dec 23, 2021
@iandunn iandunn added the [Type] Enhancement New feature or request label Dec 23, 2021
@iandunn iandunn changed the title internationalize strings and test homepage/learn/etc w/ different browser language internationalize new header/footer Dec 23, 2021
@iandunn
Copy link
Member Author

iandunn commented Dec 29, 2021

I expected something like this to work, but it doesn't at first glance:

<!-- wp:navigation-link {"label":"<?php esc_html_x( 'Privacy Policy', 'Page title', 'wporg' ); ?>","url":"https://wordpress.org/about/privacy/","kind":"custom","isTopLevelLink":true} /-->

The label ends up empty, so the link isn't rendered. I was testing on nl.w.org, and that string is translated there.

We'll need to dig in more to find out why.

Note that the mockup actually calls for Privacy rather than Privacy Policy; the above is just a test to see if it worked.

@iandunn
Copy link
Member Author

iandunn commented Dec 29, 2021

Doh, nevermind, that does work, I was just confusing esc_html_x with esc_html_e 😆

esc_html_x() doesn't echo the output, but this works:

<!-- wp:navigation-link {"label":"<?php echo esc_html_x( 'Privacy Policy', 'Page title', 'wporg' ); ?>","url":"https://wordpress.org/about/privacy/","kind":"custom","isTopLevelLink":true} /-->

@iandunn
Copy link
Member Author

iandunn commented Jan 19, 2022

@ocean90 , @dd32: I'm trying to get strings from this repo imported into GlotPress. does the diff below look correct?

should this go in it's own GP project, or the main wordpress-org one? if a new one, do i need to create that in the GP UI, or do the code changes below do it?

Index: generate-pot.sh
===================================================================
--- generate-pot.sh	(revision 18316)
+++ generate-pot.sh	(working copy)
@@ -66,6 +66,7 @@

 		wpclimakepot $CO/learn-wordpress $CO/learn-wordpress/wporg-learn.pot --exclude=wp-content/mu-plugins
 		wpclimakepot $CO/pattern-directory $CO/pattern-directory/wporg-patterns.pot --exclude=public_html/wp-content/mu-plugins --exclude=public_html/wp-content/tests --exclude=node_modules
+		wpclimakepot $CO/wporg-mu-plugins $CO/wporg-mu-plugins/wporg-mu-plugins.pot

 		# Download the Openverse file. Additional check to ensure it's at least 100 lines.
 		curl -so "$CO/openverse-frontend.pot" https://raw.githubusercontent.com/WordPress/openverse-frontend/main/src/locales/po-files/openverse.pot
Index: init-repos.sh
===================================================================
--- init-repos.sh	(revision 18316)
+++ init-repos.sh	(working copy)
@@ -36,6 +36,12 @@
 	cd $CO/pattern-directory && git fetch origin --quiet && git reset --hard origin/build --quiet
 fi

+if [ ! -d $CO/wporg-mu-plugins ]; then
+	git clone --branch trunk https://github.com/WordPress/wporg-mu-plugins.git $CO/wporg-mu-plugins
+else
+	cd $CO/wporg-mu-plugins && git fetch origin --quiet && git reset --hard origin/trunk --quiet
+fi
+
 cd $CO

 svn co https://i18n.svn.wordpress.org/tools/trunk i18n-tools
Index: update-originals-wp.sh
===================================================================
--- update-originals-wp.sh	(revision 18316)
+++ update-originals-wp.sh	(working copy)
@@ -91,6 +91,9 @@
 if [ -d "$CO/pattern-directory" ]; then
 	import_po meta/pattern-directory $CO/pattern-directory/wporg-patterns.pot
 fi
+if [ -d "$CO/wporg-mu-plugins" ]; then
+	import_po meta/wporg-mu-plugins $CO/wporg-mu-plugins/wporg-mu-plugins.pot
+fi
 if [ -d "$CO/browsehappy" ]; then
 	import_po meta/browsehappy $CO/browsehappy/languages/browsehappy.pot
 fi

@ocean90
Copy link
Member

ocean90 commented Jan 19, 2022

@iandunn I'm assuming you want continue to use the wporg text domain? In this case we should use the existing project and merge the POT files for wporg-mu-plugins and wordpress-org.
This can be done with the --merge option.

@dd32
Copy link
Member

dd32 commented Jan 20, 2022

I'm assuming you want continue to use the wporg text domain? In this case we should use the existing project and merge the POT files for wporg-mu-plugins and wordpress-org.

Agreed.

I've added this in r18321-dotorg and an incoming Meta commit will update the file references dynamically to point to the right location.

bazza pushed a commit to WordPress/wordpress.org that referenced this issue Jan 20, 2022
@dd32
Copy link
Member

dd32 commented Jan 20, 2022

if a new one, do i need to create that in the GP UI, or do the code changes below do it?

@iandunn FYI; yes you'd have to also manually create the GP project, the CLI tools don't do that automatically (Other than the custom Plugin/Theme import scripts)

@iandunn
Copy link
Member Author

iandunn commented Jan 20, 2022

Yup, those commits look good, thanks!

@iandunn
Copy link
Member Author

iandunn commented Jan 21, 2022

This is working on Rosetta sites.

It doesn't work on things like https://learn.wordpress.org/?locale=es_MX, but the old header/footer isn't translated there either, so I think that's something for another day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants