You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
538 B

4 years ago
  1. 'use strict'
  2. const path = require('path')
  3. const y18n = require('y18n')({
  4. directory: path.join(__dirname, '../../locales'),
  5. locale: 'en',
  6. updateFiles: process.env.CACACHE_UPDATE_LOCALE_FILES === 'true'
  7. })
  8. module.exports = yTag
  9. function yTag (parts) {
  10. let str = ''
  11. parts.forEach((part, i) => {
  12. const arg = arguments[i + 1]
  13. str += part
  14. if (arg) {
  15. str += '%s'
  16. }
  17. })
  18. return y18n.__.apply(null, [str].concat([].slice.call(arguments, 1)))
  19. }
  20. module.exports.setLocale = locale => {
  21. y18n.setLocale(locale)
  22. }