1
0

IL10N.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  6. * SPDX-License-Identifier: AGPL-3.0-only
  7. */
  8. // use OCP namespace for all classes that are considered public.
  9. // This means that they should be used by apps instead of the internal Nextcloud classes
  10. namespace OCP;
  11. /**
  12. * Interface IL10N
  13. *
  14. * @since 6.0.0
  15. */
  16. interface IL10N {
  17. /**
  18. * Translating
  19. * @param string $text The text we need a translation for
  20. * @param array|string $parameters default:array() Parameters for sprintf
  21. * @return string Translation or the same text
  22. *
  23. * Returns the translation. If no translation is found, $text will be
  24. * returned.
  25. * @since 6.0.0
  26. */
  27. public function t(string $text, $parameters = []): string;
  28. /**
  29. * Translating
  30. * @param string $text_singular the string to translate for exactly one object
  31. * @param string $text_plural the string to translate for n objects
  32. * @param integer $count Number of objects
  33. * @param array $parameters default:array() Parameters for sprintf
  34. * @return string Translation or the same text
  35. *
  36. * Returns the translation. If no translation is found, $text will be
  37. * returned. %n will be replaced with the number of objects.
  38. *
  39. * The correct plural is determined by the plural_forms-function
  40. * provided by the po file.
  41. * @since 6.0.0
  42. *
  43. */
  44. public function n(string $text_singular, string $text_plural, int $count, array $parameters = []): string;
  45. /**
  46. * Localization
  47. * @param string $type Type of localization
  48. * @param \DateTime|int|string $data parameters for this localization
  49. * @param array $options currently supports following options:
  50. * - 'width': handed into \Punic\Calendar::formatDate as second parameter
  51. * @return string|int|false
  52. *
  53. * Returns the localized data.
  54. *
  55. * Implemented types:
  56. * - date
  57. * - Creates a date
  58. * - l10n-field: date
  59. * - params: timestamp (int/string)
  60. * - datetime
  61. * - Creates date and time
  62. * - l10n-field: datetime
  63. * - params: timestamp (int/string)
  64. * - time
  65. * - Creates a time
  66. * - l10n-field: time
  67. * - params: timestamp (int/string)
  68. * @since 6.0.0 - parameter $options was added in 8.0.0
  69. */
  70. public function l(string $type, $data, array $options = []);
  71. /**
  72. * The code (en, de, ...) of the language that is used for this IL10N object
  73. *
  74. * @return string language
  75. * @since 7.0.0
  76. */
  77. public function getLanguageCode(): string ;
  78. /**
  79. * * The code (en_US, fr_CA, ...) of the locale that is used for this IL10N object
  80. *
  81. * @return string locale
  82. * @since 14.0.0
  83. */
  84. public function getLocaleCode(): string;
  85. }