Skip to content

Commit

Permalink
static languages method
Browse files Browse the repository at this point in the history
  • Loading branch information
penobit authored Mar 21, 2022
1 parent 01a387f commit 4854ec2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/GoogleTranslate.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,16 +336,16 @@ protected function isValidLocale(string $lang) : bool
return (bool) preg_match('/^([a-z]{2})(-[A-Z]{2})?$/', $lang);
}

public function getLanguages($assoc = false) {
public static function getLanguages($assoc = false) {
$file = __DIR__.'/languages.json';
$contents = file_get_contents($file);
$languages = json_decode($contents, $assoc);

return $languages;
}

public function getLanguage(string $lang) {
$languages = $this->getLanguages(true);
public static function getLanguage(string $lang) {
$languages = static::getLanguages(true);

return $languages[$lang] ?? null;
}
Expand Down

0 comments on commit 4854ec2

Please sign in to comment.