Skip to content

Commit

Permalink
Use single quote instead of double quote strings
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Feb 27, 2020
1 parent f91d03b commit abfaf2f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion benchmark-context.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@

$diff = $end - $start;

echo "Execution took $diff seconds\n";
echo 'Execution took ' . $diff . ' seconds' . "\n";
2 changes: 1 addition & 1 deletion benchmark-plural.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@

$diff = $end - $start;

echo "Execution took $diff seconds\n";
echo 'Execution took ' . $diff . ' seconds' . "\n";
2 changes: 1 addition & 1 deletion benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@

$diff = $end - $start;

echo "Execution took $diff seconds\n";
echo 'Execution took ' . $diff . ' seconds' . "\n";
38 changes: 30 additions & 8 deletions src/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use function getenv;
use function in_array;
use function preg_match;
use function sprintf;

class Loader
{
Expand Down Expand Up @@ -120,25 +121,46 @@ public static function listLocales($locale)
if ($modifier) {
if ($country) {
if ($charset) {
array_push($locale_names, "${lang}_$country.$charset@$modifier");
array_push(
$locale_names,
sprintf('%s_%s.%s@%s', $lang, $country, $charset, $modifier)
);
}

array_push($locale_names, "${lang}_$country@$modifier");
array_push(
$locale_names,
sprintf('%s_%s@%s', $lang, $country, $modifier)
);
} elseif ($charset) {
array_push($locale_names, "${lang}.$charset@$modifier");
array_push(
$locale_names,
sprintf('%s.%s@%s', $lang, $charset, $modifier)
);
}

array_push($locale_names, "$lang@$modifier");
array_push(
$locale_names,
sprintf('%s@%s', $lang, $modifier)
);
}

if ($country) {
if ($charset) {
array_push($locale_names, "${lang}_$country.$charset");
array_push(
$locale_names,
sprintf('%s_%s.%s', $lang, $country, $charset)
);
}

array_push($locale_names, "${lang}_$country");
array_push(
$locale_names,
sprintf('%s_%s', $lang, $country)
);
} elseif ($charset) {
array_push($locale_names, "${lang}.$charset");
array_push(
$locale_names,
sprintf('%s.%s', $lang, $charset)
);
}

array_push($locale_names, $lang);
Expand Down Expand Up @@ -181,7 +203,7 @@ public function getTranslator($domain = '')

$filename = '';
foreach ($locale_names as $locale) {
$filename = "$base/$locale/LC_MESSAGES/$domain.mo";
$filename = $base . '/' . $locale . '/LC_MESSAGES/' . $domain . '.mo';
if (file_exists($filename)) {
break;
}
Expand Down

0 comments on commit abfaf2f

Please sign in to comment.