1313 */
1414class Project
1515{
16- /**
17- * This array maps different subfolders name for Desktop products
18- * with their display name
19- */
20- public static $ components_names = [
21- 'browser ' => 'Firefox Desktop ' ,
22- 'mobile ' => 'Firefox for Android ' ,
23- 'mail ' => 'Thunderbird ' ,
24- 'suite ' => 'SeaMonkey ' ,
25- 'calendar ' => 'Lightning ' ,
26- ];
27-
2816 /*
2917 * This array contains information about supported repositories.
3018 *
@@ -52,6 +40,9 @@ class Project
5240 *
5341 */
5442 public static $ repos_info = [
43+ 'all_projects ' => [
44+ 'meta ' => true ,
45+ ],
5546 'firefox_ios ' => [
5647 'git_repository ' => 'firefoxios-l10n ' ,
5748 'locale_mapping ' => [
@@ -68,15 +59,21 @@ class Project
6859 'source_type ' => 'mixed ' ,
6960 'variable_patterns ' => ['dtd ' , 'ftl ' , 'l10njs ' , 'printf ' , 'properties ' ],
7061 ],
62+ 'comm_l10n ' => [
63+ 'source_type ' => 'mixed ' ,
64+ 'variable_patterns ' => ['dtd ' , 'ftl ' , 'l10njs ' , 'printf ' , 'properties ' ],
65+ ],
7166 'mozilla_org ' => [
7267 'git_repository ' => 'www-l10n ' ,
68+ 'git_branch ' => 'master ' ,
7369 'pontoon_project ' => 'mozillaorg ' ,
7470 'reference_locale ' => 'en ' ,
7571 'source_type ' => 'mixed ' ,
7672 'variable_patterns ' => ['ftl ' ],
7773 ],
7874 'android_l10n ' => [
7975 'git_repository ' => 'android-l10n ' ,
76+ 'git_branch ' => 'master ' ,
8077 'locale_mapping ' => [], // To avoid using Bugzilla
8178 'pontoon_project ' => 'android-l10n ' ,
8279 'source_type ' => 'xml ' ,
@@ -100,6 +97,7 @@ class Project
10097 // Desktop products
10198 'desktop ' => [
10299 'gecko_strings ' ,
100+ 'comm_l10n ' ,
103101 ],
104102 // Products using Git
105103 'git ' => [
@@ -115,10 +113,12 @@ class Project
115113 /**
116114 * Create a list of all supported repositories.
117115 *
116+ * @param boolean $exclude_meta Exclude meta project
117+ *
118118 * @return array List of supported repositories, key is the repo, value is
119119 * the nice name for the repo for display purposes.
120120 */
121- public static function getSupportedRepositories ()
121+ public static function getSupportedRepositories ($ exclude_meta = false )
122122 {
123123 // Read list of repositories from supported_repositories.json
124124 $ file_name = APP_SOURCES . 'supported_repositories.json ' ;
@@ -130,6 +130,9 @@ public static function getSupportedRepositories()
130130
131131 $ repositories = [];
132132 foreach ($ json_repositories as $ repository ) {
133+ if ($ exclude_meta && self ::isMetaRepository ($ repository ['id ' ])) {
134+ continue ;
135+ }
133136 $ repositories [$ repository ['id ' ]] = $ repository ['name ' ];
134137 }
135138
@@ -139,11 +142,13 @@ public static function getSupportedRepositories()
139142 /**
140143 * Get the list of repositories.
141144 *
145+ * @param boolean $exclude_meta Exclude meta projects
146+ *
142147 * @return array list of local repositories values
143148 */
144- public static function getRepositories ()
149+ public static function getRepositories ($ exclude_meta = false )
145150 {
146- $ repositories = array_keys (self ::getSupportedRepositories ());
151+ $ repositories = array_keys (self ::getSupportedRepositories ($ exclude_meta ));
147152 sort ($ repositories );
148153
149154 return $ repositories ;
@@ -154,11 +159,13 @@ public static function getRepositories()
154159 * The array has repo folder names as keys and Display names as value:
155160 * ex: ['firefox_ios' => 'Firefox for iOS', 'mozilla_org' => 'mozilla.org']
156161 *
162+ * @param boolean $exclude_meta Exclude meta project
163+ *
157164 * @return array list of local repositories and their Display names
158165 */
159- public static function getRepositoriesNames ()
166+ public static function getRepositoriesNames ($ exclude_meta = false )
160167 {
161- return self ::getSupportedRepositories ();
168+ return self ::getSupportedRepositories ($ exclude_meta );
162169 }
163170
164171 /**
@@ -214,6 +221,23 @@ public static function getRepositoryLocales($repository, $ignored = [])
214221 return $ supported_locales ;
215222 }
216223
224+ /**
225+ * Get the list of all locales available by looking at the meta project
226+ *
227+ * @return array A sorted list of all supported locales
228+ */
229+ public static function getAllLocales ()
230+ {
231+ $ file_name = APP_SOURCES . 'all_projects.txt ' ;
232+ $ supported_locales = [];
233+ if (file_exists ($ file_name )) {
234+ $ supported_locales = file ($ file_name , FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
235+ }
236+ sort ($ supported_locales );
237+
238+ return $ supported_locales ;
239+ }
240+
217241 /**
218242 * Get the list of repositories available for a locale
219243 *
@@ -224,7 +248,7 @@ public static function getRepositoryLocales($repository, $ignored = [])
224248 public static function getLocaleRepositories ($ locale )
225249 {
226250 $ matches = [];
227- foreach (self ::getRepositories () as $ repository ) {
251+ foreach (self ::getRepositories (true ) as $ repository ) {
228252 if (in_array ($ locale , self ::getRepositoryLocales ($ repository ))) {
229253 $ matches [] = $ repository ;
230254 }
@@ -238,7 +262,7 @@ public static function getLocaleRepositories($locale)
238262 /**
239263 * Return the reference locale for a repository
240264 *
241- * @param string $repository Name of the folder for the repository
265+ * @param string $repository Name of the repository
242266 *
243267 * @return string Name of the reference locale
244268 */
@@ -249,10 +273,37 @@ public static function getReferenceLocale($repository)
249273 : 'en-US ' ;
250274 }
251275
276+ /**
277+ * Return true if it's a meta repository
278+ *
279+ * @param string $repository Name of the repository
280+ *
281+ * @return boolean True if the repository is set as meta
282+ */
283+ public static function isMetaRepository ($ repository )
284+ {
285+ return isset (self ::$ repos_info [$ repository ]['meta ' ])
286+ ? self ::$ repos_info [$ repository ]['meta ' ]
287+ : false ;
288+ }
289+
290+ /**
291+ * Return true if the locale is the reference locale for a repository
292+ *
293+ * @param string $locale Locale code
294+ * @param string $repository Name of the repository
295+ *
296+ * @return boolean True is it's the reference locale
297+ */
298+ public static function isReferenceLocale ($ locale , $ repository )
299+ {
300+ return self ::getReferenceLocale ($ repository ) == $ locale ;
301+ }
302+
252303 /**
253304 * Check if the specified repository is supported
254305 *
255- * @param string $repository Name of the folder for the repository
306+ * @param string $repository Name of the repository
256307 *
257308 * @return boolean True if supported repository, False if unknown
258309 */
0 commit comments