ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
TranslationInMemoryRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28{
33 public function __construct(
34 private array $texts = [],
35 private array $plurals = [],
36 ) {
37 }
38
39 public function getKeys(string $module, string $lang_key, ?string $client_data_dir): ?array
40 {
41 if (!isset($this->texts[$module][$lang_key]) && !isset($this->plurals[$module][$lang_key])) {
42 return null;
43 }
44 $keys = [];
45 foreach (array_merge(array_keys($this->texts[$module][$lang_key] ?? []), array_keys($this->plurals[$module][$lang_key] ?? [])) as $key) {
46 $keys[(string) $key] = $module;
47 }
48
49 return $keys;
50 }
51
52 public function getText(string $module, string $lang_key, string $key, ?string $client_data_dir): ?string
53 {
54 return $this->texts[$module][$lang_key][$key] ?? null;
55 }
56
57 public function getPluralText(string $module, string $lang_key, string $key, int $n, ?string $client_data_dir): ?string
58 {
59 $forms = $this->plurals[$module][$lang_key][$key] ?? null;
60
61 return $forms === null ? null : $forms[$n === 1 ? 0 : 1] ?? null;
62 }
63}
Test double for TranslationRepository: serves what the test hands in, no files, build or database.
__construct(private array $texts=[], private array $plurals=[],)
getText(string $module, string $lang_key, string $key, ?string $client_data_dir)
null if there is none (not served, not translated, or a problem, see MigratedTranslations::getProblem...
getPluralText(string $module, string $lang_key, string $key, int $n, ?string $client_data_dir)
The form the plural rule of $lang_key selects for $n; null if $key is no plural message there.
getKeys(string $module, string $lang_key, ?string $client_data_dir)
Identifier => $module, null if $module is not served for $lang_key.
if(!isset($arguments[0])) if(count( $arguments) > 3) if(! $remove_from_lang &&isset($arguments[2]) &&!is_dir($arguments[2])) $module
The values the ILIAS modules serve at runtime: the shipped ones with the local changes on top (see il...