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

Only translations for enabled extensions should be loaded from language pack #2020

Merged
merged 1 commit into from
Apr 19, 2020

Conversation

rob006
Copy link
Contributor

@rob006 rob006 commented Feb 22, 2020

fixes #1837
replaces #1954

This is continuation of #1954. I fixed condition for detecting core files (validation.yml and core.yml) and tested this locally - it is working as expected.

@rob006
Copy link
Contributor Author

rob006 commented Feb 22, 2020

OK, I found one problem. Extensions that use translations but does not register Locales extender, does not trigger locale cache refresh after enabling/disabling the extension - user needs to refresh cache manually to load translations for these extensions. This affects only core extensions - they have their translations in https://github.com/flarum/lang-english/tree/master/locale. Every other extension has bundled English translation and register it using Locales extender.

I'm not sure how to proceed with this. Personally, I would just move these translation files to extensions, like in every other 3rd party extension - it seems to be more consistent and pragmatic (you don't need to open 2 PRs every time you add a new setting to extension, and you can release extensions and language pack independently).

@askvortsov1
Copy link
Member

askvortsov1 commented Feb 22, 2020

Is there a reason why core extensions don't use Locales?

@tankerkiller125
Copy link
Contributor

I'm personally in favor of moving translations to their respective extensions.

@askvortsov1
Copy link
Member

I'm personally in favor of moving translations to their respective extensions.

Should this be split into a separate issue?

@rob006
Copy link
Contributor Author

rob006 commented Feb 23, 2020

I'm personally in favor of moving translations to their respective extensions.

Another reason to do this is that English fallback (#1961) will not work for these extensions, since there will be no English translations available (unless you have English language pack installed and enabled).

Copy link
Member

@askvortsov1 askvortsov1 left a comment

Choose a reason for hiding this comment

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

I can confirm that this works, and I think it's a good idea!

@franzliedke
Copy link
Contributor

I'm personally in favor of moving translations to their respective extensions.

There was lots of discussion about this when we made that decision. I don't remember the reasoning, but I do remember it was a very deliberate decision, weighing trade-offs and all that.

Could somebody do me the favor and try to dig up that old discussion? It must have been with participation by @dcsjapan and @tobyzerner (then @tobscure). This should help us reach a conclusion here.

@franzliedke franzliedke self-requested a review April 10, 2020 19:56
@clarkwinkelmann
Copy link
Member

clarkwinkelmann commented Apr 10, 2020

Suggestion: call the Locale extender in each of the core extensions even if they have no locales files so that they clear the cache. That way we can ship this bug-free without having to make an immediate decision on whether we move language files out of the English pack.

Maybe we need an additional method on the Locale extender so that we can register an empty locale file list without having to create an empty locales folder.

@franzliedke
Copy link
Contributor

We just talked about this in our dev meeting.


Maybe we need an additional method on the Locale extender so that we can register an empty locale file list without having to create an empty locales folder.

@clarkwinkelmann I think that won't be necessary. For the current code in the extender, any directory without YAML files should do - and it might even work with non-existing directories. 😁

@tomsgad

This comment has been minimized.

@askvortsov1

This comment has been minimized.

@franzliedke franzliedke merged commit ee7a462 into flarum:master Apr 19, 2020
@franzliedke
Copy link
Contributor

Possible follow-up tasks for interested people (hint hint @rob006 @clarkwinkelmann @askvortsov1):

Updates for bundled extensions
If we want to fix this for the bundled extensions (I don't care too much), feel free to send PRs to all bundled extensions (except for the English language pack) with the following:

  1. A new file locale/.keep.
  2. A new line new Extend\Locales(__DIR__ . '/locale'), in the extension's extend.php script.

Documentation update
The convention on how to name translation files is now a stricter requirement, if I get this right. So we should mention this in the documentation.

franzliedke added a commit that referenced this pull request Apr 19, 2020
- Early returns
- Comments
- Write variables only when needed

Refs #2020.
@rob006 rob006 deleted the locale-filter branch April 19, 2020 18:56
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.

Only translations for enabled extensions should be loaded from language pack
6 participants