index.js 876 B

12345678910111213141516171819202122
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.M = void 0;
  7. const os_locale_s_fix_1 = require("os-locale-s-fix");
  8. const en_1 = __importDefault(require("./en"));
  9. const zh_CN_1 = __importDefault(require("./zh_CN"));
  10. function format(lang) {
  11. const array = lang.split(/[.,]/)[0].split(/[_-]/);
  12. array[0] = array[0].toLowerCase();
  13. if (array[0] === 'zh') {
  14. array[1] = (array[1] || 'CN').toUpperCase();
  15. }
  16. array.length = Math.min(array.length, 2);
  17. return array.join('_');
  18. }
  19. const locale = format(process.env.UNI_HBUILDERX_LANGID ||
  20. os_locale_s_fix_1.osLocale.sync({ spawn: true, cache: false }) ||
  21. 'en');
  22. exports.M = locale === 'zh_CN' ? zh_CN_1.default : en_1.default;