diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-07-05 00:41:59 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-07-05 14:33:08 +0200 |
commit | 772bbd99bee83d17707c73a630a4d47c4b8bc807 (patch) | |
tree | 9cc5293fe3454e3e71be018b80825a5686516ae5 /lib/public/L10N | |
parent | cbfcfb236f3e8ace6c64ab5a654b9a331a3ce1c0 (diff) | |
download | nextcloud-server-772bbd99bee83d17707c73a630a4d47c4b8bc807.tar.gz nextcloud-server-772bbd99bee83d17707c73a630a4d47c4b8bc807.zip |
Backend work to provide NC whats New info to users
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/public/L10N')
-rw-r--r-- | lib/public/L10N/IFactory.php | 16 | ||||
-rw-r--r-- | lib/public/L10N/ILanguageIterator.php | 74 |
2 files changed, 86 insertions, 4 deletions
diff --git a/lib/public/L10N/IFactory.php b/lib/public/L10N/IFactory.php index 9c006073200..1bc231e4e2e 100644 --- a/lib/public/L10N/IFactory.php +++ b/lib/public/L10N/IFactory.php @@ -21,6 +21,8 @@ */ namespace OCP\L10N; +use OCP\IUser; + /** * @since 8.2.0 */ @@ -93,10 +95,16 @@ interface IFactory { /** * iterate through language settings (if provided) in this order: * 1. returns the forced language or: - * 2. returns the user language or: - * 3. returns the system default language or: - * 4+∞. returns 'en' + * 2. if applicable, the trunk of 1 (e.g. "fu" instead of "fu_BAR" + * 3. returns the user language or: + * 4. if applicable, the trunk of 3 + * 5. returns the system default language or: + * 6. if applicable, the trunk of 5 + * 7+∞. returns 'en' + * + * Hint: in most cases findLanguage() suits you fine + * * @since 14.0.0 */ - public function iterateLanguage(bool $reset = false): string; + public function getLanguageIterator(IUser $user = null): ILanguageIterator; } diff --git a/lib/public/L10N/ILanguageIterator.php b/lib/public/L10N/ILanguageIterator.php new file mode 100644 index 00000000000..ef923dfd249 --- /dev/null +++ b/lib/public/L10N/ILanguageIterator.php @@ -0,0 +1,74 @@ +<?php +/** + * @copyright Copyright (c) 2018 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\L10N; + +/** + * Interface ILanguageIterator + * + * iterator across language settings (if provided) in this order: + * 1. returns the forced language or: + * 2. if applicable, the trunk of 1 (e.g. "fu" instead of "fu_BAR" + * 3. returns the user language or: + * 4. if applicable, the trunk of 3 + * 5. returns the system default language or: + * 6. if applicable, the trunk of 5 + * 7+∞. returns 'en' + * + * if settings are not present or truncating is not applicable, the iterator + * skips to the next valid item itself + * + * @package OCP\L10N + * + * @since 14.0.0 + */ +interface ILanguageIterator extends \Iterator { + + /** + * Return the current element + * + * @since 14.0.0 + */ + public function current(): string; + + /** + * Move forward to next element + * + * @since 14.0.0 + */ + public function next(); + + /** + * Return the key of the current element + * + * @since 14.0.0 + */ + public function key():int; + + /** + * Checks if current position is valid + * + * @since 14.0.0 + */ + public function valid():bool; +} |