Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cvaize committed Mar 22, 2020
1 parent 667338f commit 2f6ba6a
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion resources/assets/js/components/TranslationOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class TranslationOptions extends BoxedStateComponent {
</div>
{/*
<div className="col-sm-3">
<?php if(str_contains($userLocales, ',' . $currentLocale . ',')): ?>
<?php if(\Str::contains($userLocales, ',' . $currentLocale . ',')): ?>
<div className="input-group input-group-sm" style="float:right; display:inline">
<?= ifEditTrans($package . '::messages.in-place-edit') ?>
<label htmlFor="edit-in-place">&nbsp;</label>
Expand Down
6 changes: 3 additions & 3 deletions resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class="btn btn-sm btn-info input-control"
<input type="hidden" name="_token"
value="<?php echo csrf_token(); ?>">
</form>
<?php endif; ?>
<?php endif; ?>
<form id="form-publish-all" class="form-inline form-publish-all" method="POST"
action="<?= action($controller . '@postPublish', '*') ?>"
data-remote="true" role="form">
Expand Down Expand Up @@ -312,7 +312,7 @@ class="btn btn-sm btn-info input-control"
</div>
</div>
<div class=" col-sm-3">
<?php if(str_contains($userLocales, ',' . $currentLocale . ',')): ?>
<?php if(\Str::contains($userLocales, ',' . $currentLocale . ',')): ?>
<div class="input-group input-group-sm" style="float:right; display:inline">
<?= ifEditTrans($package . '::messages.in-place-edit') ?>
<label for="edit-in-place">&nbsp;</label>
Expand Down Expand Up @@ -865,7 +865,7 @@ function postDeleteKeys(event) {
var URL_TRANSLATOR_FILTERS = '<?= action($controller . '@getTransFilters') ?>';
var CURRENT_GROUP = '<?= $group ?>';
var MARKDOWN_KEY_SUFFIX = '<?= $markdownKeySuffix ?>';
// provide translations for JavaScript
var MISMATCHED_QUOTES_MESSAGE = "<?= noEditTrans(($package . '::messages.mismatched-quotes'))?>";
var TITLE_SAVE_CHANGES = "<?= noEditTrans(($package . '::messages.title-save-changes'))?>";
Expand Down
2 changes: 1 addition & 1 deletion resources/views/mismatched.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
$mismatches[] = null;
$locale = $translatingLocale;
$translator = App::make('translator');
$isLocaleEnabled = str_contains($userLocales, ',' . $locale . ',');
$isLocaleEnabled = \Str::contains($userLocales, ',' . $locale . ',');
foreach($mismatches as $mismatch)
{
if ($mismatch === null) break;
Expand Down
8 changes: 4 additions & 4 deletions resources/views/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
</tr>
</thead>
<tbody>
<?php
$translator = App::make('translator');
<?php
$translator = App::make('translator');
foreach ($translations as $t):
$groupUrl = action($controller . '@getView', $t->group);
$isLocaleEnabled = str_contains($userLocales, ',' . $t->locale . ',');
$groupUrl = action($controller . '@getView', $t->group);
$isLocaleEnabled = \Str::contains($userLocales, ',' . $t->locale . ',');
if ($t->group === Manager::JSON_GROUP && $t->locale === 'json' && $t->value === null || $t->value === '') {
$t->value = $t->key;
}
Expand Down
4 changes: 2 additions & 2 deletions resources/views/translations-table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<span class="key-filter" id="key-filter"><?=$translationRows?></span>
</th>
<?php foreach($locales as $locale): ?>
<?php $isLocaleEnabled = str_contains($userLocalesString, ',' . $locale . ','); ?>
<?php $isLocaleEnabled = \Str::contains($userLocalesString, ',' . $locale . ','); ?>
<?php if (!array_key_exists($locale, $useDisplayLocales)) continue; ?>
<?php $jsonAdjustedLocale = $locale === 'json' ? app('translator')->get($package . '::messages.json-key') : $locale;if ($col < 3): ?>
<?php if ($col === 0): ?>
Expand Down Expand Up @@ -164,7 +164,7 @@ class="show-source-refs" data-method="POST" data-remote="true" title="<?php echo
</a><?php
} ?></td>
<?php foreach($locales as $locale): ?>
<?php $isLocaleEnabled = str_contains($userLocalesString, ',' . $locale . ','); ?>
<?php $isLocaleEnabled = \Str::contains($userLocalesString, ',' . $locale . ','); ?>
<?php if (!array_key_exists($locale, $useDisplayLocales)) continue; ?>
<?php $t = isset($translation[$locale]) ? $translation[$locale] : null ?>
<td class="<?= $locale !== $primaryLocale ? 'auto-translatable-' . $locale : ($locale === $primaryLocale ? 'auto-fillable' : '') ?><?= ($has_changed[$locale] ? ' has-unpublished-translation' : '') . ($has_changes_cached[$locale] ? ' has-cached-translation' : '') ?>">
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/PathTemplateResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ protected function loadFileList($prefix, $path_parts, $group_parts)
$prefix = str_replace("\\", "/", $prefix);

for (; ;) {
$isUnderBaseDir = $prefix == $this->normalized_base_path || starts_with($prefix . '/', $this->normalized_base_path . '/');
$isUnderBaseDir = $prefix == $this->normalized_base_path || \Str::startsWith($prefix . '/', $this->normalized_base_path . '/');

if (array_key_exists($prefix, $this->processed_dirs) || ($isUnderBaseDir && (!file_exists($prefix) || !is_dir($prefix)))) {
// already handled this one or it does not exist and not under base dir
Expand Down
14 changes: 7 additions & 7 deletions src/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct()

$this->cookiePrefix = $this->manager->config('persistent_prefix', 'K9N6YPi9WHwKp6E3jGbx');

// cookies are not available yet (they are but appear to be encrypted). They will be by the time middleware is called
// cookies are not available yet (they are but appear to be encrypted). They will be by the time middleware is called
$this->middleware(function ($request, $next) {
$this->manager->setWebUI(); // no need to clear
$this->initialize();
Expand Down Expand Up @@ -245,14 +245,14 @@ public function isLocaleEnabled($locale)
$packLocales = TranslationLocales::packLocales($this->transLocales->userLocales);
if (!is_array($locale)) $locale = array($locale);
foreach ($locale as $item) {
if (!str_contains($packLocales, ',' . $item . ',')) return false;
if (!\Str::contains($packLocales, ',' . $item . ',')) return false;
}
return true;
}

/*
* Standard WEB UI - API, not REST
*
*
*/

public function getSearch()
Expand Down Expand Up @@ -679,7 +679,7 @@ protected static function keyGroup($group, $key)
$prefix = '';
$gkey = $key;

if (starts_with($key, 'vnd:') || starts_with($key, 'wbn:')) {
if (\Str::startsWith($key, 'vnd:') || \Str::startsWith($key, 'wbn:')) {
// these have vendor with . afterwards in the group
$parts = explode('.', $key, 2);

Expand Down Expand Up @@ -891,7 +891,7 @@ public static function webRoutes()
Route::get('publish/{group}', '\\Vsch\\TranslationManager\\Controller@getPublish');
Route::get('import', '\\Vsch\\TranslationManager\\Controller@getImport');

// shared web and api urls
// shared web and api urls
// TODO: migrate to Rest Controller for implementation
Route::post('edit/{group}', '\\Vsch\\TranslationManager\\Controller@postEdit');
Route::post('undelete/{group}/{key}', '\\Vsch\\TranslationManager\\Controller@postUndelete');
Expand All @@ -912,7 +912,7 @@ public static function routes($disableReactUI)

/*
* React UI - API
*
*
*/
public static function apiRoutes($disableReactUI)
{
Expand Down Expand Up @@ -948,7 +948,7 @@ public static function apiRoutes($disableReactUI)

Route::post('api/trans-filters', '\\Vsch\\TranslationManager\\Controller@apiTransFilters');

// shared web and api urls
// shared web and api urls
// TODO: migrate to Rest Controller for implementation
Route::post('api/delete/{group}/{key}', '\\Vsch\\TranslationManager\\Controller@postDelete');
Route::post('api/edit/{group}', '\\Vsch\\TranslationManager\\Controller@postEdit');
Expand Down
16 changes: 8 additions & 8 deletions src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function firstOrNewTranslation($attributes = null)
&& array_key_exists($attributes['locale'], $this->preloadedGroupLocales)
) {
$checkDB = false;

if (array_key_exists($attributes['key'], $this->preloadedGroupKeys)
&& array_key_exists($attributes['locale'], $this->preloadedGroupKeys[$attributes['key']])
) {
Expand Down Expand Up @@ -390,7 +390,7 @@ public function getGroupAugmentedList()
$this->augmentedGroupReverseList = [];

foreach ($groupList as $group) {
if (starts_with($group, ["vnd:", "wbn:"])) {
if (\Str::startsWith($group, ["vnd:", "wbn:"])) {
// we need this one
$parts = explode('.', $group, 2);
if (count($parts) === 2) {
Expand Down Expand Up @@ -656,7 +656,7 @@ public function cachedTranslations($namespace, $group, $locale, $translations =
$localePrefix = "$locale:";
$prefixLen = strlen($localePrefix);
foreach ($values as $key => $translation) {
if (str_starts_with($key, $localePrefix)) {
if (\Str::startsWith($key, $localePrefix)) {
$transKey = substr($key, $prefixLen);
$translations[$transKey] = $translation;
}
Expand Down Expand Up @@ -856,7 +856,7 @@ function importTranslationFile($locale, $db_group, $translations, $replace)
$dbTranslations = $this->translatorRepository->selectTranslationsByLocaleAndGroup($locale, $db_group);
$inDatabasePublishing = $this->inDatabasePublishing();

// we are either in-database publishing or writing the files but pretending that we are for a remote
// we are either in-database publishing or writing the files but pretending that we are for a remote
// connection which is really limited to do in-database publishing only
$inDatabasePublishing = $inDatabasePublishing === 1 || $inDatabasePublishing === 2 ? $inDatabasePublishing : 0;

Expand Down Expand Up @@ -1297,8 +1297,8 @@ function findTranslations($path = null)
foreach ($matches[3] as $index => $key) {
$quote = $matches[2][$index][0];
$keyValue = $key[0];
if ($quote == '\'' && !str_contains($keyValue, ["\"", "'", "->",]) ||
$quote == '"' && !str_contains($keyValue, ["$", "\"", "'", "->",])
if ($quote == '\'' && !\Str::contains($keyValue, ["\"", "'", "->",]) ||
$quote == '"' && !\Str::contains($keyValue, ["$", "\"", "'", "->",])
) {
if ($fileLines == null) {
$fileLines = self::computeFileLines($fileContents);
Expand Down Expand Up @@ -1659,7 +1659,7 @@ function makeTree($translations)
protected
function getLostDotTranslation($translations, $tree)
{
// check if all translation values are in the array or some were lost because of invalid dot notation for keys
// check if all translation values are in the array or some were lost because of invalid dot notation for keys
$nonArrays = array();
foreach ($translations as $translation) {
$group = $translation->group;
Expand All @@ -1668,7 +1668,7 @@ function getLostDotTranslation($translations, $tree)
$value = array_get($tree[$translation->locale][$translation->group], $translation->key);

if (is_array($value)) {
// this one is an array while it is a translation in the source
// this one is an array while it is a translation in the source
$nonArrays[$group][$key] = $translation;
}
}
Expand Down

0 comments on commit 2f6ba6a

Please sign in to comment.