Skip to content

Add localizations update on post-deploy script #10

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

doxigo
Copy link
Contributor

@doxigo doxigo commented Jun 16, 2021

Considering the move we're making towards in-theme translation, it'd be nice to have the locale:update included in post-deployment script, is already added on multiple major projects of ours

Considering the move we're making towards in-theme translation, it'd be nice to have the `locale:update` included in post-deployment script, is already added on multiple major projects of ours
@esolitos
Copy link

Considering the move we're making towards in-theme translation

Have we ever not used the i18n setup via t() (and friends)?

Note that what you suggest slows down each deploy by a couple of minutes, this should be better handled with a nightly cron job instead, or also a CI/CD schedule which syncs the configuration translations. IMHO the locale:update shouldnot be part of the deploy,
When we add custom translations we should use .po tracked files generated by locale:export and rather include a locale:import in the post-deployment.

@doxigo
Copy link
Contributor Author

doxigo commented Jun 16, 2021

@esolitos we can skip locale:check to save some time on deploys, not sure the difference between locale:import and if it does import the strings added in the theme's .po file

@szeidler
Copy link
Member

locale:check to save some time on deploys, not sure the difference between locale:import

The difference is minor. locale:update has some kind of a cache. So it does not perform the underlying locale:check operations, when running it twice in 2 minutes. I think the time limit is 10 minutes, so most likely will not be relevant in our case with a couple of minutes per deployment. But it also means, that "locale:update" will in most cases do the slow check as well.

That being said: i don't think a nightly translation update is enough. When I work on a multilingual site and get the translations from the client, I will add them right away to the .po file of the corresponding custom module or theme and want to have the strings available immediately after I deployed it. Otherwise the customer will complain: "But what's with the Norwegian translation".
That's the reason, I added the drush locale:check && drush locale:update to wodby.yml for a couple of projects, especially the ones with multiple environments, so that the interface translations for the custom functionality are always in sync.

@szeidler
Copy link
Member

11:20:42  INFO [command] exec: Update localizations
11:20:42  INFO [Update localizations][command] exec output: 2021-06-15 11:20:42.819 +0000 (346 346) warning: User instrumentation from opcache: opcache status information is not an array
11:20:43  INFO [Update localizations][command] exec output: > 2021-06-15 11:20:43.272 +0000 (362 362) warning: User instrumentation from opcache: opcache status information is not an array
11:20:43  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for drupal.
11:20:43  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for admin_toolbar.
11:20:43  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for admin_toolbar_mediteran.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for allowed_formats.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for atom.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for components.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for config_filter.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for config_ignore.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for config_split.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for content_lock.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for content_translation_redirect.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for crop.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for ctools.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for default_content.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for default_content_deploy.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for emulsify_twig.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for entity.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for entity_clone.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for entity_update.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for eu_cookie_compliance.
11:20:44  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for facets.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for facets_pretty_paths.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for field_group.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for file_delete.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for focal_point.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for google_analytics.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for google_tag.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for gutenberg.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for http_cache_control.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for language_switcher_extended.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for media_library_edit.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for metatag.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for metatag_async_widget.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for module_filter.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for monolog.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for onomasticon.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for openid_connect.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for pathauto.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for profile.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for publication_date.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for purge.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for queue_ui.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for redirect.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for redis.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for responsive_preview.
11:20:45  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for scheduler.
11:20:46  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for scheduler_content_moderation_integration.
11:20:46  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for search_api.
11:20:46  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for search_api_solr.
11:20:46  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for site_settings.
11:20:46  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for subpathauto.
11:20:46  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for svg_image.
11:20:46  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for title_length.
11:20:46  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for token.
11:20:46  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for twig_field_value.
11:20:46  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for twig_tweak.
11:20:46  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for ultimate_cron.
11:20:46  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for unified_twig_ext.
11:20:47  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for varnish_purge.
11:20:47  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for view_unpublished.
11:20:47  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for views_infinite_scroll.
11:20:47  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for ***.
11:20:47  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for ***.
11:20:47  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for ***.
11:20:47  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for ***.
11:20:47  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for ***.
11:20:47  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for ***.
11:20:47  INFO [Update localizations][command] exec output: >  [notice] Checked nb translation for ***.
11:20:47  INFO [Update localizations][command] exec output: >  [notice] Message: Kontrollerte tilgjengelige oversettelser for 68 prosjekter.
11:20:47  INFO [Update localizations][command] exec output: > 
11:20:47  INFO [Update localizations][command] exec output: 2021-06-15 11:20:47.240 +0000 (345 345) warning: User instrumentation from opcache: opcache status information is not an array
11:20:47  INFO [Update localizations][command] exec output: > 2021-06-15 11:20:47.665 +0000 (395 395) warning: User instrumentation from opcache: opcache status information is not an array
11:20:53  INFO [Update localizations][command] exec output: >  [notice] Imported nb translation for ***.
11:20:53  INFO [Update localizations][command] exec output: >  [notice] Imported nb translation for ***.
11:20:53  INFO [Update localizations][command] exec output: >  [notice] Imported nb translation for ***.
11:20:53  INFO [Update localizations][command] exec output: >  [notice] Imported nb translation for ***.
11:20:53  INFO [Update localizations][command] exec output: >  [notice] Imported nb translation for ***.
11:20:53  INFO [Update localizations][command] exec output: >  [notice] Imported nb translation for ***.
11:20:57  INFO [Update localizations][command] exec output: >  [warning] Message: There have been some configuration changes. It is advisable to download and 
11:20:57  INFO [Update localizations][command] exec output: > deploy an updated config.zip to your Solr server.
11:20:57  INFO [Update localizations][command] exec output: > 
11:20:57  INFO [Update localizations][command] exec output: >  [warning] Message: A new Solr field type has been installed due to configuration changes. It is 
11:20:57  INFO [Update localizations][command] exec output: > advisable to download and deploy an updated config.zip to your Solr server.
11:20:57  INFO [Update localizations][command] exec output: > 
11:20:57  INFO [Update localizations][command] exec output: >  [notice] Message: 6 oversettelsesfiler importert. /0/ oversettelser ble lagt til, /42/ 
11:20:57  INFO [Update localizations][command] exec output: > oversettelser ble oppdatert og /0/ oversettelser ble fjernet.

Here's the wodby deployment log for a site, using that approach. I replaced the custom modules/themes with *** since it's public here in github.

@esolitos
Copy link

Did I understand correctly that locale:update does also handle .po files provided with custom modules?
If so, I was not aware and this changes everything!

@szeidler
Copy link
Member

Yes, you can make .po files in your module behave like a Drupal translation server. Sounds like a ramday session. I introduced a paradigm quite a while back for translations in custom themes and modules :D

That would go into mymodule.info.yml.

'interface translation project': mymodule
'interface translation server pattern': 'modules/custom/mymodule/translations/%language.po'

Works also for themes.

Copy link

@esolitos esolitos left a comment

Choose a reason for hiding this comment

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

I believe this is rather useful given the last @szeidler feedback.

I really do not like the additional time we add on the post-deployment script, but I guess there's no really workaround to this, and comes with the benefit that we always get the updated translations on deploy, so overall it is likely a positive outcome.

@doxigo
Copy link
Contributor Author

doxigo commented Jun 24, 2021

Perfect, @szeidler if you also approve the PR, could we merge and close?

Copy link

@esolitos esolitos left a comment

Choose a reason for hiding this comment

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

We need to handle the case where drupal is not installed yet (first deploy) and when Locale is not installed.


- name: Update localizations
type: command
command: drush locale:check && drush locale:update

Choose a reason for hiding this comment

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

I have experienced an issue with this. It breaks if the locale module is not installed and on the first deploys.

We need to add contingency for those two cases before we can merge it for all sites.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, @esolitos do you have any suggestions/workaround for this?

@doxigo
Copy link
Contributor Author

doxigo commented Feb 11, 2022

Also tagging @mnlund @szeidler

@szeidler
Copy link
Member

Also tagging @mnlund @szeidler

The comment from Marlon would need to be resolved, before being able to merge it.

Copy link
Member

@szeidler szeidler left a comment

Choose a reason for hiding this comment

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

Post deployment step also needs to work if locale is not installed.

@doxigo
Copy link
Contributor Author

doxigo commented Sep 20, 2023

@szeidler if we don't have any solution for this, we can close this PR

@szeidler
Copy link
Member

There is a solution, just not implemented :P

@szeidler
Copy link
Member

Since we have been using the method on some sites I noticed the following: During the last few months I see that the deployment gets quite a big hit, when using the command on websites with a lot of contrib modules. The reason is, that the localization server responds relatively slow to our requests from Wodby. Considering that the majority of deploys do not include any localization updates we maybe should keep it as an opt-in setting like now?

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

Successfully merging this pull request may close these issues.

3 participants