getAvailableLangs() documentation & feature request
See original GitHub issueI’m submitting a…
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[X] Feature request
[X] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:
Current behavior
Calling getAvailableLangs()
returns either a string[]
or something like [{ id: 'en', label: 'English' }, { id: 'es', label: 'Spanish' }]
. This makes it difficult to use this method to check if a saved language is available to use within the app (when persisting language outside of the @ngneat/transloco-persist-translations
).
The documentation also lacks information about this method, only stating Gets the available languages:
, without giving any information on the return type(s), and how to actually use it to check if a language is available for example.
Expected behavior
First of all I expect better documentation on getAvailableLangs()
than almost literally the method name with spaces.
Secondly, I would like to see a method like isAvailableLang(string)
, to check if a given string is included in the specified availableLangs (+ lowercase on both language abbreviations would be nice to have).
What is the motivation / use case for changing the behavior?
When using a custom way of persisting a language, it doesn’t seem right to just call setActiveLang(...)
without knowing if the specified language is even an available language. To prevent all kind of errors it would be nice to have a solid way of checking the specified language.
Environment
Angular version: not applicable
Browser:
- [X] not applicable
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Ok that’s fine! Thanks for the update.
@SansDK we are waiting for https://github.com/ngneat/transloco/pull/184 to release the new version with your changes