Merge pull request #527 from huangzhhui/fix-translator-cannot-use-repeatedly

Fixed translator cannot translate repeatedly
This commit is contained in:
李铭昕 2019-09-05 09:22:04 +08:00 committed by GitHub
commit ddff309db9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -12,6 +12,7 @@
- [#479](https://github.com/hyperf-cloud/hyperf/pull/479) Fixed typehint error when host of Elasticsearch client does not reached. - [#479](https://github.com/hyperf-cloud/hyperf/pull/479) Fixed typehint error when host of Elasticsearch client does not reached.
- [#508](https://github.com/hyperf-cloud/hyperf/pull/508) Fixed return type error of `Hyperf\Utils\Coroutine::parentId()` when running in non-coroutine environment. - [#508](https://github.com/hyperf-cloud/hyperf/pull/508) Fixed return type error of `Hyperf\Utils\Coroutine::parentId()` when running in non-coroutine environment.
- [#514](https://github.com/hyperf-cloud/hyperf/pull/514) Fixed redis auth failed when the password is an empty string. - [#514](https://github.com/hyperf-cloud/hyperf/pull/514) Fixed redis auth failed when the password is an empty string.
- [#527](https://github.com/hyperf-cloud/hyperf/pull/527) Fixed translator cannot translate repeatedly.
# v1.0.13 - 2019-08-28 # v1.0.13 - 2019-08-28

View File

@ -267,16 +267,15 @@ class Translator implements TranslatorInterface
$parsed = $this->parseNamespacedSegments($key); $parsed = $this->parseNamespacedSegments($key);
} }
if (is_null($parsed[0])) {
$parsed[0] = '*';
}
// Once we have the parsed array of this key's elements, such as its groups // Once we have the parsed array of this key's elements, such as its groups
// and namespace, we will cache each array inside a simple list that has // and namespace, we will cache each array inside a simple list that has
// the key and the parsed array for quick look-ups for later requests. // the key and the parsed array for quick look-ups for later requests.
$segments = $this->parsed[$key] = $parsed;
if (is_null($segments[0])) { return $this->parsed[$key] = $parsed;
$segments[0] = '*';
}
return $segments;
} }
/** /**