File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -195,4 +195,10 @@ export default interface TranslatorInterface<
195195 * Clear the stored translations
196196 */
197197 clear ( ) : void ;
198+
199+ /**
200+ * Get available languages within domain
201+ * @param {string } domain - the translation domain
202+ */
203+ getAvailableLanguages ( domain : string ) : string [ ] ;
198204}
Original file line number Diff line number Diff line change @@ -329,4 +329,24 @@ export default class Translator<
329329 // emptying
330330 this . #translatorEntries = { } ;
331331 }
332+
333+ /**
334+ * @inheritDoc
335+ */
336+ public getAvailableLanguages ( domain : string ) : string [ ] {
337+ if ( ! is_string ( domain ) ) {
338+ return [ ] ;
339+ }
340+ let languages : string [ ] = [ ] ;
341+ if ( ! this . #translatorEntries[ domain ] ) {
342+ return languages ;
343+ }
344+ for ( let language in this . #translatorEntries[ domain ] ) {
345+ if ( ! this . #translatorEntries[ domain ] . hasOwnProperty ( language ) ) {
346+ continue ;
347+ }
348+ languages . push ( language ) ;
349+ }
350+ return languages
351+ }
332352}
You can’t perform that action at this time.
0 commit comments