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
LanguageHub dependency: Completely remove all references to LanguageHub from the codebase.
- Update to
libLanguage v0.1.0:
- Update
virion.yml and .poggit.yml to use libLanguage version 0.1.0.
- Use the new
LanguageLoader utility to load internal plugin translations.
- Implement Explicit API:
- Expose a public method (e.g.,
getLocaleResolver()) in the Main class that returns the ManagedLocaleResolver.
- This allows other plugins to explicitly request the resolver from
LanguageManager instead of relying on a broken global hub.
- Update Commands:
- Refactor
ListLangsCommand, SetLangCommand, and others to work without LanguageHub.
- The available languages for the
/setlang command should now be managed directly within LanguageManager (e.g., based on its own loaded languages or a list in config.yml).
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.
Transition to Isolated libLanguage Architecture and Decoupled API
Description
The current architecture of
LanguageManagerrelies on theLanguageHubsingleton fromlibLanguagev0.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
LanguageManagerto use the new isolated architecture oflibLanguagev0.1.0.Plan
LanguageHubdependency: Completely remove all references toLanguageHubfrom the codebase.libLanguagev0.1.0:virion.ymland.poggit.ymlto uselibLanguageversion0.1.0.LanguageLoaderutility to load internal plugin translations.getLocaleResolver()) in theMainclass that returns theManagedLocaleResolver.LanguageManagerinstead of relying on a broken global hub.ListLangsCommand,SetLangCommand, and others to work withoutLanguageHub./setlangcommand should now be managed directly withinLanguageManager(e.g., based on its own loaded languages or a list inconfig.yml).Expected Outcome
Other plugins will be able to integrate with
LanguageManagerusing a simple check:This ensures a robust, working localization system that respects player preferences across the entire server.