Jump to content

[Mod Request] Invert Prefix Mod for Latin-based Languages


Salsa

Recommended Posts

Since now certain items can include adjectives (or intensifiers) as prefixes, I need a mod to actually make them suffixes. When localizing a game to a latin-based language, the position of adjectives is inverted. There are exceptions and ways to circumvent this rule whenever you're translating, but it's not foolproof and it's not ideal for the reader.

 

That being said, could anyone help me with a mod for that so I can include it in my localization mod? I'll make sure to give proper credits.

 

Also, has anyone found a Belissa Plumilla surrogate to compensate for the lack of specific accentuation in it (i.e. ^ and ~)?

 

 

Thanks for your time!

Link to comment
Share on other sites

@Salsa

Put the suffixed_adjectives.lua file (within the attached zip) in your mod folder, and then add

modimport "suffixed_adjectives.lua"
to your modmain.lua. This makes all the game's adjectives appear as suffixes, instead of prefixes.

This does not take care of strings the game stores as complete sentences, such as "Add Wet Fuel", but it should take care of all automatically built ones where an adjective is attached to a separate noun.

The "Very Wet Goop" case is still problematic, though, since simply putting the adverb at the end (as my script does) is not a solution.

Qualquer dúvida, é só perguntar.

EDIT: I updated the script to handle the Wet Goop as a special case. The wet modifier ("Very") is now placed before the last word of the name, which should give you "Gosma Muito Molhada" once the adverb has been translated (right now it gives "Gosma Very Molhada" with your translation).

suffixed_adjectives.zip

Link to comment
Share on other sites

You sir are a master of your craft! I cannot measure the gratitude in mundane words.

 

Thanks a lot! This will prove mighty useful! I'll let you know of any future developments involving this.

Link to comment
Share on other sites

@Salsa

Put the suffixed_adjectives.lua file (within the attached zip) in your mod folder, and then add

modimport "suffixed_adjectives.lua"
to your modmain.lua. This makes all the game's adjectives appear as suffixes, instead of prefixes.

This does not take care of strings the game stores as complete sentences, such as "Add Wet Fuel", but it should take care of all automatically built ones where an adjective is attached to a separate noun.

The "Very Wet Goop" case is still problematic, though, since simply putting the adverb at the end (as my script does) is not a solution.

Qualquer dúvida, é só perguntar.

EDIT: I updated the script to handle the Wet Goop as a special case. The wet modifier ("Very") is now placed before the last word of the name, which should give you "Gosma Muito Molhada" once the adverb has been translated (right now it gives "Gosma Very Molhada" with your translation).

 

 

Pretty good mod thanks. I'm working on the french version and it's usefull.

 

I've found another prefix that don't work :

 

RABBITHOLE = "Collapsed",

Link to comment
Share on other sites

  • Developer

I've just finished implementing my system. It's less clever about sorting out the phrasing for you. Instead, I've focused on giving more control (and responsibility) to the translator/modder, to increase its accessibility and make it easy to add new strings from other mods.

 

I added two tables and four functions to the dlcsupport.lua file.

 

USE_PREFIX is a table that allows you to specify which strings will be prepended and which strings will be appended (i.e. prefix or suffix). If the value for the key is set to true, it will prepend the string associated with that key (all the key names are the same as their string table keys). If it's set to false, it will append the string.

USE_PREFIX["SMOLDERINGITEM"] = trueUSE_PREFIX["WITHEREDITEM"] = trueUSE_PREFIX["FOOD"] = trueUSE_PREFIX["CLOTHING"] = trueUSE_PREFIX["TOOL"] = trueUSE_PREFIX["FUEL"] = trueUSE_PREFIX["GENERIC"] = trueUSE_PREFIX["GOOP"] = true -- Special case using inst.wet_prefix set on wet goop to WET_PREFIX.GOOPUSE_PREFIX["RABBITHOLE"] = true -- Special case using inst.wet_prefix on rabbit hole set to WET_PREFIX.RABBITHOLE

NORMALIZE_PREFIX_KEY is a table that exists to make the prefix functions below able to accept a slightly more flexible set of parameters (the display string or the prefab name in the cases here) and make sure it's looking up the right prefix value in the USE_PREFIX table.

NORMALIZE_PREFIX_KEY["WETGOOP"] = "GOOP"NORMALIZE_PREFIX_KEY["WET GOOP"] = "GOOP"NORMALIZE_PREFIX_KEY["RABBIT HOLE"] = "RABBITHOLE"

MakeAllSuffixes() is a function that will set all items to use a suffix/appended adjective.

function MakeAllSuffixes()    for i,v in pairs(USE_PREFIX) do        USE_PREFIX[i] = false    endend

MakeAllPrefixes() is a function that will set all items to use a prefix/prepended adjective.

function MakeAllPrefixes()    for i,v in pairs(USE_PREFIX) do        USE_PREFIX[i] = true    endend

SetUsesPrefix(item, usePrefix) is a function that allows you to specify if a particular item should use a prefix or a suffix. It can also be used to add items to the table.

function SetUsesPrefix(item, usePrefix)    if type(item) ~= "string" then item = tostring(item) end    if item and item ~= "nil" and usePrefix ~= nil then        item = string.upper(item)        if NORMALIZE_PREFIX_KEY[item] then item = NORMALIZE_PREFIX_KEY[item] end        USE_PREFIX[item] = usePrefix    endend

UsesPrefix(item) is a function that allows you to check whether the specified item uses a prefix or a suffix.

function UsesPrefix(item)    if type(item) ~= "string" then item = tostring(item) end    if item and item ~= "nil" then        item = string.upper(item)        if NORMALIZE_PREFIX_KEY[item] then item = NORMALIZE_PREFIX_KEY[item] end        return USE_PREFIX[item]    endend

Lastly, I updated the EntityScript:GetDisplayName() function so that it checks UsesPrefix for each item before returning a string (it will return a string with the appropriate adjective added before or after the name based on the return value of UsesPrefix).

 

The one clear shortcoming of this approach that I can see is that it doesn't allow you to insert the adverb "Very" in between "Wet" and "Goop". I've decided to leave it that way because the "Wet" in "Wet Goop" is not actually part of the prefix system. It's the name of the object and in my opinion, any weirdness that comes from that should be solved by translation (i.e. treating it as an item called "Goop" instead), rather than by code handling weird edge cases.

 

If this doesn't seem like it will cover all your bases, let me know and we can talk about what it's missing.

Link to comment
Share on other sites

The one clear shortcoming of this approach that I can see is that it doesn't allow you to insert the adverb "Very" in between "Wet" and "Goop". I've decided to leave it that way because the "Wet" in "Wet Goop" is not actually part of the prefix system. It's the name of the object and in my opinion, any weirdness that comes from that should be solved by translation (i.e. treating it as an item called "Goop" instead), rather than by code handling weird edge cases.

 

If this doesn't seem like it will cover all your bases, let me know and we can talk about what it's missing.

 

Yeah, it's only one instance it's not that difficult to solve.

 

As for the code itself I don't know how I could implement that in a mod, since I'm just the translator, hehe. But I guess @simplex could use it for an updated version of his mod.

 

Currently, the only problem is the uniqueness of gender for each item, but I decided to just say for example Wet = Molhado(a). That way the general gender is masculine and the reader will understand it accordingly.

Link to comment
Share on other sites

If this doesn't seem like it will cover all your bases, let me know and we can talk about what it's missing.

This seems like an adequate solution to me. If I may, the only extension to the system I'd like to request is the possibility of storing functions, and not just booleans in the USE_PREFIX table. Then, when the entry to USE_PREFIX is a function, it gets called on the entity, the prefix and the name instead of just concatenating the latter two. More precisely, what I'm suggesting is combining the prefix with the name as follows:

--// Returns the final display name.local function applyPrefix(inst, prefix, name)	local uses_prefix	if type(inst.prefab) == "string" then		uses_prefix = UsesPrefix(inst.prefab)	else		uses_prefix = true	end	if type(uses_prefix) == "function" then		return uses_prefix(inst, prefix, name)	elseif uses_prefix then		return prefix.." "..name	else		return name.." "..prefix	endend
Then I could tackle the wet goop case via:

SetUsesPrefix("goop", function(inst, prefix, name)	if prefix == inst.wet_prefix then		local first_part, last_word = name:match("^(.-)(%S+)$")		if first_part and #first_part > 0 then			assert( first_part:match("%s$") ) --// if it didn't, it would have zero length due to the non-greedy matching.			return first_part..prefix.." "..last_word		end	end	return name.." "..prefixend)

As for the code itself I don't know how I could implement that in a mod, since I'm just the translator, hehe. But I guess @simplex could use it for an updated version of his mod.

Yes, I could implement that. But don't call it my mod, the mod is yours, I just wrote a script to help you out.

Link to comment
Share on other sites

  • Developer

This seems like an adequate solution to me. If I may, the only extension to the system I'd like to request is the possibility of storing functions, and not just booleans in the USE_PREFIX table. Then, when the entry to USE_PREFIX is a function, it gets called on the entity, the prefix and the name instead of just concatenating the latter two. 

 

Yeah, you bet. Thanks for the input! (Sorry for the late reply--was working on adding support for mod configuration options the past couple days)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...