You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
3.6 KiB

3 years ago
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Bart Visscher <bartv@thisnet.nl>
  7. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  8. * @author Georg Ehrke <oc.list@georgehrke.com>
  9. * @author Joas Schilling <coding@schilljs.com>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Roeland Jago Douma <roeland@famdouma.nl>
  12. * @author Thomas Citharel <nextcloud@tcit.fr>
  13. *
  14. * @license AGPL-3.0
  15. *
  16. * This code is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License, version 3,
  18. * as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License, version 3,
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>
  27. *
  28. */
  29. /**
  30. * Public interface of ownCloud for apps to use.
  31. * L10n interface
  32. *
  33. */
  34. // use OCP namespace for all classes that are considered public.
  35. // This means that they should be used by apps instead of the internal ownCloud classes
  36. namespace OCP;
  37. /**
  38. * Interface IL10N
  39. *
  40. * @since 6.0.0
  41. */
  42. interface IL10N {
  43. /**
  44. * Translating
  45. * @param string $text The text we need a translation for
  46. * @param array|string $parameters default:array() Parameters for sprintf
  47. * @return string Translation or the same text
  48. *
  49. * Returns the translation. If no translation is found, $text will be
  50. * returned.
  51. * @since 6.0.0
  52. */
  53. public function t(string $text, $parameters = []): string;
  54. /**
  55. * Translating
  56. * @param string $text_singular the string to translate for exactly one object
  57. * @param string $text_plural the string to translate for n objects
  58. * @param integer $count Number of objects
  59. * @param array $parameters default:array() Parameters for sprintf
  60. * @return string Translation or the same text
  61. *
  62. * Returns the translation. If no translation is found, $text will be
  63. * returned. %n will be replaced with the number of objects.
  64. *
  65. * The correct plural is determined by the plural_forms-function
  66. * provided by the po file.
  67. * @since 6.0.0
  68. *
  69. */
  70. public function n(string $text_singular, string $text_plural, int $count, array $parameters = []): string;
  71. /**
  72. * Localization
  73. * @param string $type Type of localization
  74. * @param \DateTime|int|string $data parameters for this localization
  75. * @param array $options currently supports following options:
  76. * - 'width': handed into \Punic\Calendar::formatDate as second parameter
  77. * @return string|int|false
  78. *
  79. * Returns the localized data.
  80. *
  81. * Implemented types:
  82. * - date
  83. * - Creates a date
  84. * - l10n-field: date
  85. * - params: timestamp (int/string)
  86. * - datetime
  87. * - Creates date and time
  88. * - l10n-field: datetime
  89. * - params: timestamp (int/string)
  90. * - time
  91. * - Creates a time
  92. * - l10n-field: time
  93. * - params: timestamp (int/string)
  94. * @since 6.0.0 - parameter $options was added in 8.0.0
  95. */
  96. public function l(string $type, $data, array $options = []);
  97. /**
  98. * The code (en, de, ...) of the language that is used for this IL10N object
  99. *
  100. * @return string language
  101. * @since 7.0.0
  102. */
  103. public function getLanguageCode(): string ;
  104. /**
  105. * * The code (en_US, fr_CA, ...) of the locale that is used for this IL10N object
  106. *
  107. * @return string locale
  108. * @since 14.0.0
  109. */
  110. public function getLocaleCode(): string;
  111. }