/** * Get the correct form of a word * * @param string $word The word to fetch * @param string $patterns A particular patterns array to fetch from * @return string Correct form of the word */ protected static function getWord($word, $patterns = 'patterns') { // If the world is invariable, don't touch it if (static::invariable($word)) { return $word; } // If it's irregular, return the correct form if (!is_null(static::irregular($word))) { return static::irregular($word); } // Else look for patterns ans replace foreach (Babel::translate('accord/' . static::$repository . '.' . $patterns) as $pattern => $replace) { if (preg_match($pattern, $word)) { return preg_replace($pattern, $replace, $word); } } // Special case for english language to use Laravel's plural function if (Babel::lang() == 'en' and static::$repository == 'plurals') { return Str::plural($word); } return $word; }
/** * Accord an adjective * * @param string $adjective An adjective * @return string An accorded adjective */ public static function adjective($adjective) { $message = Message::current(); switch (Babel::lang()) { case 'fr': if ($message->isFemale()) { $adjective .= 'e'; } if (Word::isPlural($message->noun) or $message->number > 1) { $adjective .= 's'; } } return $adjective; }