JoliTypo\Fixer::setLocale PHP Method

setLocale() public method

Change the locale of the Fixer.
public setLocale ( string $locale )
$locale string An IETF language tag
    public function setLocale($locale)
    {
        if (!is_string($locale) || empty($locale)) {
            throw new \InvalidArgumentException('Locale must be an IETF language tag.');
        }
        // Set the Locale on Fixer that needs it
        foreach ($this->_rules as $rule) {
            if ($rule instanceof LocaleAwareFixerInterface) {
                $rule->setLocale($locale);
            }
        }
        $this->locale = $locale;
    }

Usage Example

Exemplo n.º 1
0
 public function __construct()
 {
     // get locale
     $this->locale = Config::get('letterpress.locale');
     // defaults
     if (Config::get('letterpress.microtypography.useDefaults')) {
         $this->fixers = Config::get('jolitypo.defaults');
         // locale additions
         $localeKey = sprintf('jolitypo.%s', $this->locale);
         if (Config::has($localeKey)) {
             $this->fixers = array_merge($this->fixers, Config::get($localeKey));
         }
     }
     // hyphenation
     if (Config::get('letterpress.microtypography.enableHyphenation')) {
         $this->fixers[] = 'Hyphen';
     }
     // user additions
     $this->fixers = array_merge($this->fixers, Config::get('letterpress.microtypography.additionalFixers'));
     if (count($this->fixers) === 0) {
         throw new LetterpressException('Typography fixing requires setting up fixers.');
     }
     $this->fixer = new Fixer($this->fixers);
     $this->fixer->setLocale($this->locale);
 }
All Usage Examples Of JoliTypo\Fixer::setLocale