From d4833b7ca901dfa3a7563798a201b21f7d524a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Dobro=C5=88?= Date: Tue, 7 Nov 2023 09:00:33 +0100 Subject: [PATCH] Custom updates --- README.md | 8 ++++---- docs/collection.md | 2 +- docs/getting_started.md | 2 +- src/fbt/FbtConfig.php | 1 + src/fbt/Runtime/Gender.php | 2 +- src/fbt/Services/TranslationsGeneratorService.php | 8 ++++---- src/fbt/Transform/FbtHash.php | 8 ++++---- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1ba4047..edbb476 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,10 @@ FBT is an internationalization framework for PHP designed to be not just **power **This library is based on the JavaScript implementation of Facebook's [FBT][link-facebook-fbt].** -FBT intro -FBT plurals -FBT enum -FBT pronouns +FBT intro +FBT plurals +FBT enum +FBT pronouns ## Requirements * PHP 7.0 or higher diff --git a/docs/collection.md b/docs/collection.md index 851387f..8296533 100644 --- a/docs/collection.md +++ b/docs/collection.md @@ -44,7 +44,7 @@ can produce the translated payloads `fbt::_()` expects. When it comes to moving from source text to translations, what is most pertinent is the `hashToText` payload containing all relevant texts -with their identifying hash. You can choose `md5` or `tiger` hash module. It defaults to md5. +with their identifying hash. You can choose `md5` or `tiger` hash module. It defaults to `md5`. ### A note on hashes diff --git a/docs/getting_started.md b/docs/getting_started.md index a3de904..1c4d6a7 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -41,7 +41,7 @@ Below are the less important parameters. * **collectFbt** `bool`: (Default: `true`) Collect fbt instances from the source and store them to a JSON file. * **prettyPrint** `bool`: (Default: `true`) Pretty print source strings in a JSON file. -* **hash_module** `string`: (Default: `md5`) Hash module. +* **hash_module** `string`: (Default: `md5`) Hash module. You can choose `md5` or `tiger` hash module. * **md5_digest** `string`: (Default: `hex`) MD5 digest. * **driver** `string`: (Default: `json`) Currently, only JSON storage is supported. diff --git a/src/fbt/FbtConfig.php b/src/fbt/FbtConfig.php index 736ebd9..ff9ae67 100644 --- a/src/fbt/FbtConfig.php +++ b/src/fbt/FbtConfig.php @@ -113,6 +113,7 @@ public static function set(string $key, $value) } /** + * @param array $config * @return void * @throws FbtInvalidConfigurationException */ diff --git a/src/fbt/Runtime/Gender.php b/src/fbt/Runtime/Gender.php index 4fc6b19..15cdb3e 100644 --- a/src/fbt/Runtime/Gender.php +++ b/src/fbt/Runtime/Gender.php @@ -191,7 +191,7 @@ class Gender ], ]; - public static function getData($gender, $usage) + public static function getData(string $gender, string $usage) { $data = self::DATA; diff --git a/src/fbt/Services/TranslationsGeneratorService.php b/src/fbt/Services/TranslationsGeneratorService.php index cd22d88..4fe5cfe 100644 --- a/src/fbt/Services/TranslationsGeneratorService.php +++ b/src/fbt/Services/TranslationsGeneratorService.php @@ -135,7 +135,7 @@ private function processTranslations(array $fbtSites, array $group): array /** * @throws \fbt\Exceptions\FbtException */ - private function processGroups($phrases, $translatedGroups): array + private function processGroups(array $phrases, array $translatedGroups): array { $localeToHashToFbt = []; @@ -156,12 +156,12 @@ private function processGroups($phrases, $translatedGroups): array * Generate missing translation hashes from collected source strings * * @param string $source - * @param $translationsPath - * @param $inputPath + * @param string|null $translationsPath + * @param string $inputPath * * @throws \Exception */ - public function generateTranslations(string $source, $translationsPath, $inputPath) + public function generateTranslations(string $source, ?string $translationsPath, string $inputPath) { if (! file_exists($source)) { throw new \Exception('Source strings file does not exist: ' . $source); diff --git a/src/fbt/Transform/FbtHash.php b/src/fbt/Transform/FbtHash.php index e1433c2..cab1f95 100644 --- a/src/fbt/Transform/FbtHash.php +++ b/src/fbt/Transform/FbtHash.php @@ -19,9 +19,9 @@ class FbtHash * * [["hash1", "hash2", ...]] */ - public static function md5($phrases): array + public static function md5(array $phrases): array { - return array_map(function ($phrase) { + return array_map(function (array $phrase) { return array_map( function ($text) use ($phrase) { $md5 = md5($text . $phrase['desc']); @@ -60,9 +60,9 @@ function ($text) use ($phrase) { * ["hash1", "hash2", ...], // hashes for strings of phrase N * ] */ - public static function tiger($phrases): array + public static function tiger(array $phrases): array { - return array_map(function ($phrase) { + return array_map(function (array $phrase) { return array_map( function ($text) use ($phrase) { return FbtTransform\fbtHash::oldTigerHash($text . ':::' . $phrase['desc'] . ':');