Skip to content

WIP: [IMPR] Language handling for Components#11421

Open
chfsx wants to merge 1 commit intoILIAS-eLearning:trunkfrom
srsolutionsag:improvement/12/component-languages
Open

WIP: [IMPR] Language handling for Components#11421
chfsx wants to merge 1 commit intoILIAS-eLearning:trunkfrom
srsolutionsag:improvement/12/component-languages

Conversation

@chfsx
Copy link
Copy Markdown
Member

@chfsx chfsx commented Apr 13, 2026

As mentioned in today’s JF, components (e.g. third-party ones) are not yet able to manage language files.
This PR at least restores the behaviour whereby components can also provide language files, just as plugins have done up to now.

However, this is merely a workaround; in my opinion, the Language component should be structured much more effectively. At present, one needs a great deal of technical knowledge regarding the component’s inner workings for the translation to function. But to continue contributing translations as a (plugin) component, at least for the time being, this would be one way forward.
The interface \ILIAS\Language\ComponentTranslation\LanguageFileDirectory could then be deprecated at a later date once a new mechanism is in place, thereby supporting both types during a transitional period.

As an example, I’ve rewritten the File component so that it has its own language files. However, whether or not to do this would definitely be a separate decision.

@alex40724 | @mjansenDatabay FYI since you were involved in todays discussion

I marked this PR as WIP since I will remove the part for the fileobject if accepted.

array | \ArrayAccess &$internal,
): void {
$define[] = \ILIAS\Language\Language::class;
$contribute[LanguageFileDirectory::class] = static fn()=> new MainLanguageFileDirectory();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The current directory /lang is provided here. Only one instance of MainLanguageFileDirectory can be provided.

$pull[Factory::class]
);

$contribute[LanguageFileDirectory::class] = fn(): LanguageFileDirectory => new ComponentLanguageFileDirectory(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is an example of how a component provides it's own lang-directory. Since the ComponentLanguageFileDirectory must provide the prefix (to avoid collisions), the prefixes can be removed in the language files

if ($scope === "local") {
$path = $this->cust_lang_path;
}
foreach ($this->language_file_directory_manager->getDirectories() as $directory) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Most of the magic starts here. Instead of just reading files in /lang, we iterate all provided directories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants