init.lua 1.2 KB

1234567891011121314151617181920212223242526
  1. local S, NS = core.get_translator("testtranslations")
  2. local function send_compare(name, text)
  3. core.chat_send_player(name, ("%s | %s | %s"):format(
  4. core.get_translated_string("", text), text, core.get_translated_string("fr", text)))
  5. end
  6. core.register_chatcommand("testtranslations", {
  7. params = "",
  8. description = "Test translations",
  9. privs = {},
  10. func = function(name, param)
  11. core.chat_send_player(name, "Please ensure your locale is set to \"fr\"")
  12. core.chat_send_player(name, "Untranslated | Client-side translation | Server-side translation (fr)")
  13. send_compare(name, S("Testing .tr files: untranslated"))
  14. send_compare(name, S("Testing .po files: untranslated"))
  15. send_compare(name, S("Testing .mo files: untranslated"))
  16. send_compare(name, S("Testing fuzzy .po entry: untranslated (expected)"))
  17. send_compare(name, core.translate("translation_po", "Testing .po without context: untranslated"))
  18. send_compare(name, core.translate("translation_mo", "Testing .mo without context: untranslated"))
  19. for i = 0,4 do
  20. send_compare(name, NS("@1: .po singular", "@1: .po plural", i, tostring(i)))
  21. send_compare(name, NS("@1: .mo singular", "@1: .mo plural", i, tostring(i)))
  22. end
  23. end
  24. })