LanguageInterface.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. namespace Drupal\Core\Language;
  3. /**
  4. * Defines a language.
  5. */
  6. interface LanguageInterface {
  7. /**
  8. * Special system language code (only applicable to UI language).
  9. *
  10. * Refers to the language used in Drupal and module/theme source code. Drupal
  11. * uses the built-in text for English by default, but if configured to allow
  12. * translation/customization of English, we need to differentiate between the
  13. * built-in language and the English translation.
  14. */
  15. const LANGCODE_SYSTEM = 'system';
  16. /**
  17. * The language code used when no language is explicitly assigned (yet).
  18. *
  19. * Should be used when language information is not available or cannot be
  20. * determined. This special language code is useful when we know the data
  21. * might have linguistic information, but we don't know the language.
  22. *
  23. * See http://www.w3.org/International/questions/qa-no-language#undetermined.
  24. */
  25. const LANGCODE_NOT_SPECIFIED = 'und';
  26. /**
  27. * The language code used when the marked object has no linguistic content.
  28. *
  29. * Should be used when we explicitly know that the data referred has no
  30. * linguistic content.
  31. *
  32. * See http://www.w3.org/International/questions/qa-no-language#nonlinguistic.
  33. */
  34. const LANGCODE_NOT_APPLICABLE = 'zxx';
  35. /**
  36. * Language code referring to the default language of data, e.g. of an entity.
  37. *
  38. * See the BCP 47 syntax for defining private language tags:
  39. * http://www.rfc-editor.org/rfc/bcp/bcp47.txt
  40. */
  41. const LANGCODE_DEFAULT = 'x-default';
  42. /**
  43. * Language code referring to site's default language.
  44. */
  45. const LANGCODE_SITE_DEFAULT = 'site_default';
  46. /**
  47. * The language state when referring to configurable languages.
  48. */
  49. const STATE_CONFIGURABLE = 1;
  50. /**
  51. * The language state when referring to locked languages.
  52. */
  53. const STATE_LOCKED = 2;
  54. /**
  55. * The language state used when referring to all languages.
  56. */
  57. const STATE_ALL = 3;
  58. /**
  59. * The language state used when referring to the site's default language.
  60. */
  61. const STATE_SITE_DEFAULT = 4;
  62. /**
  63. * The type of language used to define the content language.
  64. */
  65. const TYPE_CONTENT = 'language_content';
  66. /**
  67. * The type of language used to select the user interface.
  68. */
  69. const TYPE_INTERFACE = 'language_interface';
  70. /**
  71. * The type of language used for URLs.
  72. */
  73. const TYPE_URL = 'language_url';
  74. /**
  75. * Language written left to right. Possible value of $language->direction.
  76. */
  77. const DIRECTION_LTR = 'ltr';
  78. /**
  79. * Language written right to left. Possible value of $language->direction.
  80. */
  81. const DIRECTION_RTL = 'rtl';
  82. /**
  83. * Gets the name of the language.
  84. *
  85. * @return string
  86. * The human-readable name of the language (in the language that was
  87. * used to construct this object).
  88. */
  89. public function getName();
  90. /**
  91. * Gets the ID (language code).
  92. *
  93. * @return string
  94. * The language code.
  95. */
  96. public function getId();
  97. /**
  98. * Gets the text direction (left-to-right or right-to-left).
  99. *
  100. * @return string
  101. * Either self::DIRECTION_LTR or self::DIRECTION_RTL.
  102. */
  103. public function getDirection();
  104. /**
  105. * Gets the weight of the language.
  106. *
  107. * @return int
  108. * The weight, used to order languages with larger positive weights sinking
  109. * items toward the bottom of lists.
  110. */
  111. public function getWeight();
  112. /**
  113. * Returns whether this language is the default language.
  114. *
  115. * @return bool
  116. * Whether the language is the default language.
  117. */
  118. public function isDefault();
  119. /**
  120. * Returns whether this language is locked.
  121. *
  122. * @return bool
  123. * Whether the language is locked or not.
  124. */
  125. public function isLocked();
  126. }