mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-20 15:12:57 +00:00
Adds preference to control multilingual behaviour (#7064)
* Adds preference to control multilingual behaviour Examine mode preference should persist across reconnections to a single round Still looking into how to properly get these to go into the savefile * typos
This commit is contained in:
@@ -148,8 +148,8 @@
|
||||
/mob/proc/find_valid_prefixes(message)
|
||||
var/list/prefixes = list() // [["Common", start, end], ["Gutter", start, end]]
|
||||
for(var/i in 1 to length(message))
|
||||
// This grabs trimmed 3 character substrings, to allow for up to 1 prefix and 1 letter language keys
|
||||
var/selection = trim_right(lowertext(copytext(message, i, i + 2)))
|
||||
// This grabs 3 character substrings, to allow for up to 1 prefix, 1 letter language key, and one post-key character to more strictly control where the language breaks happen
|
||||
var/selection = lowertext(copytext(message, i, i + 3))
|
||||
// The first character in the selection will always be the prefix (if this is a valid language invocation)
|
||||
var/prefix = copytext(selection, 1, 2)
|
||||
var/language_key = copytext(selection, 2, 3)
|
||||
@@ -157,6 +157,18 @@
|
||||
// Okay, we're definitely now trying to invoke a language (probably)
|
||||
// This "[]" is probably unnecessary but BYOND will runtime if a number is used
|
||||
var/datum/language/L = GLOB.language_keys["[language_key]"]
|
||||
|
||||
// MULTILINGUAL_SPACE enforces a space after the language key
|
||||
if(client && (client.prefs.multilingual_mode == MULTILINGUAL_SPACE) && (text2ascii(copytext(selection, 3, 4)) != 32)) // If we're looking for a space and we don't find one
|
||||
continue
|
||||
|
||||
// MULTILINGUAL_DOUBLE_DELIMITER enforces a delimiter (valid prefix) after the language key
|
||||
if(client && (client.prefs.multilingual_mode == MULTILINGUAL_DOUBLE_DELIMITER) && !is_language_prefix(copytext(selection, 3, 4)))
|
||||
continue
|
||||
|
||||
if(client && (client.prefs.multilingual_mode in list(MULTILINGUAL_DEFAULT)))
|
||||
selection = copytext(selection, 1, 3) // These modes only use two characters, not three
|
||||
|
||||
// It's kinda silly that we have to check L != null and this isn't done for us by can_speak (it runtimes instead), but w/e
|
||||
if(L && can_speak(L))
|
||||
// So we have a valid language invocation, and we can speak that language, let's make a piece for it
|
||||
@@ -170,6 +182,10 @@
|
||||
// This covers the case of "no prefixes in use."
|
||||
prefixes[++prefixes.len] = list(get_default_language(), i, i)
|
||||
|
||||
// If multilingualism is disabled, then after the first pass we're guaranteed to have either found a language key at the start, or else there isn't one and we're using the default for the whole message
|
||||
if(client && (client.prefs.multilingual_mode == MULTILINGUAL_OFF))
|
||||
break
|
||||
|
||||
return prefixes
|
||||
|
||||
/mob/proc/strip_prefixes(message, mob/prefixer = null)
|
||||
|
||||
Reference in New Issue
Block a user