phrase.js 833 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { language_pl_pl } from "../languages/pl_pl";
  2. export class phrase {
  3. #text;
  4. static #dictionary;
  5. static #init() {
  6. phrase.#dictionary = language_pl_pl;
  7. }
  8. get dictionary() {
  9. if (!phrase.#dictionary) {
  10. phrase.#init()
  11. }
  12. return phrase.#dictionary;
  13. }
  14. constructor(location) {
  15. const splited = location.split(".");
  16. let dict = this.dictionary;
  17. for (let count in splited) {
  18. if (!(splited[count] in dict)) {
  19. this.#text = location;
  20. break;
  21. }
  22. dict = dict[splited[count]];
  23. }
  24. if (!this.#text) {
  25. this.#text = dict;
  26. }
  27. }
  28. toString() {
  29. return this.#text;
  30. }
  31. get text() {
  32. return this.#text;
  33. }
  34. }