diff --git a/Classes/Fusion/Implementation.php b/Classes/Fusion/Implementation.php index 812db31..a2d7bd6 100644 --- a/Classes/Fusion/Implementation.php +++ b/Classes/Fusion/Implementation.php @@ -13,6 +13,12 @@ class Implementation extends AbstractFusionObject { + /** + * @Flow\InjectConfiguration() + * @var array + */ + protected $settings; + /** * @Flow\Inject * @var Environment @@ -84,6 +90,10 @@ public function evaluate() $language = str_replace('_', '-', strtolower($this->getLocale())); + if (isset($this->settings['mapping'][$language]) && is_string($this->settings['mapping'][$language])) { + $language = $this->settings['mapping'][$language]; + } + if (!$this->texFileExists($language)) { $firstPartOfLanguage = explode('-', $language)[0]; if ($firstPartOfLanguage === $language) { diff --git a/Configuration/Settings.Carbon.yaml b/Configuration/Settings.Carbon.yaml new file mode 100755 index 0000000..6263579 --- /dev/null +++ b/Configuration/Settings.Carbon.yaml @@ -0,0 +1,6 @@ +Carbon: + Hyphen: + mapping: + en: en-gb + de-de: de + de-at: de diff --git a/README.md b/README.md index c4c8e9d..08b19bf 100755 --- a/README.md +++ b/README.md @@ -73,6 +73,19 @@ prototype(Foo.Bar:Component) { **throwException** (boolean, default = `true`) : Throw exception if no hyphen definition is found +## Custom language mappings + +Probably you've got a language defined that is not available in syllable. For example, `en` is not available, but `en-gb` is. Because of that, you can map your language preset to another syllable language: Per default following settings are set in [Settings.Carbon.yaml]: + +```yaml +Carbon: + Hyphen: + mapping: + en: en-gb + de-de: de + de-at: de +``` + ## Credits This implementation was heavily inspired by [packagefactory/hyphenate]. @@ -89,4 +102,5 @@ This implementation was heavily inspired by [packagefactory/hyphenate]. [subscription]: https://github.com/CarbonPackages/Carbon.Hyphen/subscription [phpsyllable]: https://github.com/vanderlee/phpSyllable [syllable languages]: https://github.com/vanderlee/phpSyllable/tree/master/languages +[settings.carbon.yaml]: Configuration/Settings.Carbon.yaml [packagefactory/hyphenate]: https://github.com/PackageFactory/hyphenate