Skip to content

Commit

Permalink
added languages functions
Browse files Browse the repository at this point in the history
  • Loading branch information
penobit authored Mar 21, 2022
1 parent b33eef2 commit 01a387f
Show file tree
Hide file tree
Showing 2 changed files with 748 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/GoogleTranslate.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,18 @@ protected function isValidLocale(string $lang) : bool
{
return (bool) preg_match('/^([a-z]{2})(-[A-Z]{2})?$/', $lang);
}

public 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);

return $languages[$lang] ?? null;
}
}
Loading

0 comments on commit 01a387f

Please sign in to comment.