1
0

IL10N.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. // use OCP namespace for all classes that are considered public.
  30. // This means that they should be used by apps instead of the internal ownCloud classes
  31. namespace OCP;
  32. /**
  33. * Interface IL10N
  34. *
  35. * @since 6.0.0
  36. */
  37. interface IL10N {
  38. /**
  39. * Translating
  40. * @param string $text The text we need a translation for
  41. * @param array|string $parameters default:array() Parameters for sprintf
  42. * @return string Translation or the same text
  43. *
  44. * Returns the translation. If no translation is found, $text will be
  45. * returned.
  46. * @since 6.0.0
  47. */
  48. public function t(string $text, $parameters = []): string;
  49. /**
  50. * Translating
  51. * @param string $text_singular the string to translate for exactly one object
  52. * @param string $text_plural the string to translate for n objects
  53. * @param integer $count Number of objects
  54. * @param array $parameters default:array() Parameters for sprintf
  55. * @return string Translation or the same text
  56. *
  57. * Returns the translation. If no translation is found, $text will be
  58. * returned. %n will be replaced with the number of objects.
  59. *
  60. * The correct plural is determined by the plural_forms-function
  61. * provided by the po file.
  62. * @since 6.0.0
  63. *
  64. */
  65. public function n(string $text_singular, string $text_plural, int $count, array $parameters = []): string;
  66. /**
  67. * Localization
  68. * @param string $type Type of localization
  69. * @param \DateTime|int|string $data parameters for this localization
  70. * @param array $options currently supports following options:
  71. * - 'width': handed into \Punic\Calendar::formatDate as second parameter
  72. * @return string|int|false
  73. *
  74. * Returns the localized data.
  75. *
  76. * Implemented types:
  77. * - date
  78. * - Creates a date
  79. * - l10n-field: date
  80. * - params: timestamp (int/string)
  81. * - datetime
  82. * - Creates date and time
  83. * - l10n-field: datetime
  84. * - params: timestamp (int/string)
  85. * - time
  86. * - Creates a time
  87. * - l10n-field: time
  88. * - params: timestamp (int/string)
  89. * @since 6.0.0 - parameter $options was added in 8.0.0
  90. */
  91. public function l(string $type, $data, array $options = []);
  92. /**
  93. * The code (en, de, ...) of the language that is used for this IL10N object
  94. *
  95. * @return string language
  96. * @since 7.0.0
  97. */
  98. public function getLanguageCode(): string ;
  99. /**
  100. * * The code (en_US, fr_CA, ...) of the locale that is used for this IL10N object
  101. *
  102. * @return string locale
  103. * @since 14.0.0
  104. */
  105. public function getLocaleCode(): string;
  106. }