summaryrefslogtreecommitdiffstats
path: root/tests/Stubs/Dictionary.php
blob: 52e8a8940945c4d9508ffdf2d62a9674aa83dfb2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

/**
 * Test stub for the legacy global Dictionary class.
 * Provides deterministic number formatting and simple translations.
 */
class Dictionary
{
	public static function number(float $n, int $decimals = 0): string
	{
		// Deterministic formatting: dot as decimal separator, no thousands separator
		return number_format($n, max(0, $decimals), '.', '');
	}

	public static function translate(string $key, $arg = null): string
	{
		$map = [
			'lang_today' => 'today',
			'lang_yesterday' => 'yesterday',
			'lang_yes' => 'Yes',
			'lang_no' => 'No',
			'global' => 'Global',
		];
		return $map[$key] ?? $key;
	}

	// Additional helpers used by Module
	public static function translateFileModule(string $module, string $file, string $key, $default = false)
	{
		// For tests, pretend no translation exists -> return false so Module falls back to !!name!! or page title fallback
		return $default;
	}

	public static function getCategoryName(?string $id): string
	{
		return 'Cat:' . ($id ?? '');
	}
}