IL10N.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 Joas Schilling <coding@schilljs.com>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. * @author Thomas Citharel <tcit@tcit.fr>
  12. *
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. /**
  29. * Public interface of ownCloud for apps to use.
  30. * L10n interface
  31. *
  32. */
  33. // use OCP namespace for all classes that are considered public.
  34. // This means that they should be used by apps instead of the internal ownCloud classes
  35. namespace OCP;
  36. /**
  37. * Interface IL10N
  38. *
  39. * @package OCP
  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. }