-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Transition to Isolated libLanguage Architecture and Decoupled API
Description
The current architecture of LanguageManager relies on the LanguageHub singleton from libLanguage v0.0.1. Due to how PocketMine-MP virions are shaded into individual plugins, a global singleton inside a virion is not functional across different plugins.
To fix this, we need to migrate LanguageManager to use the new isolated architecture of libLanguage v0.1.0.
Plan
- Remove
LanguageHubdependency: Completely remove all references toLanguageHubfrom the codebase. - Update to
libLanguagev0.1.0:- Update
virion.ymland.poggit.ymlto uselibLanguageversion0.1.0. - Use the new
LanguageLoaderutility to load internal plugin translations.
- Update
- Implement Explicit API:
- Expose a public method (e.g.,
getLocaleResolver()) in theMainclass that returns theManagedLocaleResolver. - This allows other plugins to explicitly request the resolver from
LanguageManagerinstead of relying on a broken global hub.
- Expose a public method (e.g.,
- Update Commands:
- Refactor
ListLangsCommand,SetLangCommand, and others to work withoutLanguageHub. - The available languages for the
/setlangcommand should now be managed directly withinLanguageManager(e.g., based on its own loaded languages or a list inconfig.yml).
- Refactor
Expected Outcome
Other plugins will be able to integrate with LanguageManager using a simple check:
$manager = $this->getServer()->getPluginManager()->getPlugin("LanguageManager");
/** @var ManagedLocaleResolver|null $resolver */
$resolver = ($manager instanceof Main && $manager->isEnabled()) ? $manager->getLocaleResolver() : null;
$this->translator = new PluginTranslator($this, $languages, $resolver);This ensures a robust, working localization system that respects player preferences across the entire server.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers