IL10N.php 3.6 KB

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