File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1124,4 +1124,57 @@ public static function getLocaleInfo($code)
11241124
11251125 return $ result ;
11261126 }
1127+
1128+ /**
1129+ * Returns the list of languages
1130+ *
1131+ * @param bool $excludeCompounds Exclude compounds languages (eg 'Brazilian Portuguese', 'Traditional Chinese')?
1132+ * @param bool $excludeFake Exclude fake languages (eg 'Unknown Language', 'No linguistic content')?
1133+ * @return boolean
1134+ */
1135+ public static function getLanguages ($ excludeCompounds = false , $ excludeFake = false )
1136+ {
1137+ $ result = static ::$ languageNames ;
1138+ if ($ excludeCompounds ) {
1139+ $ keysToKeep = array_filter (
1140+ array_keys ($ result ),
1141+ function ($ key ) {
1142+ return (strpos ($ key , '_ ' ) === false ) ? true : false ;
1143+ }
1144+ );
1145+ $ result = array_intersect_key ($ result , array_flip ($ keysToKeep ));
1146+ }
1147+ if ($ excludeFake ) {
1148+ unset($ result ['und ' ]);
1149+ unset($ result ['zxx ' ]);
1150+ }
1151+
1152+ return $ result ;
1153+ }
1154+
1155+ /**
1156+ * Returns the list of territories
1157+ *
1158+ * @param bool $excludeRegions Exclude the regions (eg 'World', 'Europe')?
1159+ * @param bool $excludeFake Exclude fake territories (eg 'Unknown Region')?
1160+ */
1161+ public static function getTerritories ($ excludeRegions = false , $ excludeFake = false )
1162+ {
1163+ $ result = static ::$ territoryNames ;
1164+ if ($ excludeRegions ) {
1165+ unset($ result ['EU ' ]);
1166+ $ keysToKeep = array_filter (
1167+ array_keys ($ result ),
1168+ function ($ key ) {
1169+ return preg_match ('/^\d{3}$/ ' , $ key ) ? false : true ;
1170+ }
1171+ );
1172+ $ result = array_intersect_key ($ result , array_flip ($ keysToKeep ));
1173+ }
1174+ if ($ excludeFake ) {
1175+ unset($ result ['ZZ ' ]);
1176+ }
1177+
1178+ return $ result ;
1179+ }
11271180}
You can’t perform that action at this time.
0 commit comments