-
Notifications
You must be signed in to change notification settings - Fork 12
Inflection Files (LPlus Files)
Well, well, well... seems like someone's decided to put a little extra effort into making their MoreLocalesCulture. If your language changes the form of the adjective to match the noun, then what you need is an inflection file!
Tiny Disclaimer: Inflection files are still experimental, and you might not be able to do absolutely everything with them. If there's a feature you think they should have, please tell me in the Discord server.
Inflection files are files you can put in your mod's folder that will contain all the information needed for the mod to make decision about how exactly to:
- Recognize a noun's inflection data (for now, it's just grammatical gender and grammatical number)
- Based on that noun's inflection data, know how to change prefixes attached to it to match.
That may sound like it'll be a lot of work, but it really depends. The inflection file for Spanish, for example, is only 22 lines long so far, and it probably won't get much bigger.
The file itself is really just a text file, but with the .lplus extension (which is used recognize these files when the mod loads), structured in a specific way, kinda like your JSONs or your TOMLs or your YAMLs or your MDs or your HTMLs or your XMLs or your KMLs or your TEXs or your INIs or your ʷᵉʳ ᵗʸᵘᵒᵖᵃ ˢᵈ ᶠᵍʰʲᵏˡ ᶻˣ ᶜᵛᵇⁿᵐ...
Anyway, here's the 'specification'.
Note: Inflection files use inflection patterns. Read about those here.
LPlus files are UTF-8 text files, just like the Hjson files used by tModLoader for localization. This is their structure:
- Sections are the outermost possible scope where data can reside. They're marked using square brackets (
[]) around a section name. - Subsections are sections under sections, and they're the only other scope where data can reside. They're marked using angle brackets (
<>) around a subsection name. - Fields are what actually hold the data inside sections and subsections. They have the same structure as HJSON fields:
Key: Value. - Both sections and subsections can have tags attached to them.
Comments can be added using either two forward slashes (//) or a hash (#), just like in Hjson files.
Here's what a basic LPlus file could look like (excuse the bad highlighting):
# Section with no tags
[Section1]
# Field inside a section
FieldInSection: This is a field.
# Basic subsection
<SubsectionA>
# Array fields inside a subsection
Animals: dog, cat, cow, pig
Fruits: apple, banana, kumquat, aubergine
# Subsection with one tag
# Also, notice how subsections (and also sections) can have no data inside.
<SubsectionB:TagForSubsectionB>
# Section with 2 tags
[Section2:TagForSection2A,TagForSection2B]Pretty simple, right? But LPlus files are a little more specific. Let's go section by section.
It's important to note that only these sections will be recognized as valid by the parser. Otherwise an error will be thrown.
[Inflections] is the most important section in an LPlus file. It contains nearly everything related to noun inflection recognition and adjective form generation.
It does not take any tags.
Everything in this section is optional, as it depends on what language you're working with.
The Word field resides directly in this section. It contains a set of inflection patterns that should be skipped when trying to determine the inflection of a multiword name. Generally, these should be conjunctions, particles, and other linguistic units that are not relevant to recognizing inflection.
Note that if you do include the Word field, it must be the first field in the section. Otherwise, an error will be thrown.
Also, please note that the capabilities of this field will likely be greater in a future update, which is why here, all patterns specified must be negative patterns (with an exclamation mark (!) at the very beginning).
This set of fields, which resides directly in this section, contains the bulk of the information relating to working with inflection. You can think of it as a 2D grid, or a table. Here's a simplified version of the table for es-ES:
MascSg: -o, -e, -or
FemSg: -a, -a, -ora
MascPl: -os, -es, -ores
FemPl: -as, -as, -orasAnd here it is as an actual table. It might help you visualize:
| Paradigms | ||||
|---|---|---|---|---|
| 0 | 1 | 2 | ||
| Inflections | MascSg | -o | -e | -or |
| FemSg | -a | -a | -ora | |
| MascPl | -os | -es | -ores | |
| FemPl | -as | -as | -oras |
Each column of the table define paradigms, i. e. specific ways that a word can be inflected. You can think of paradigms as being equivalent to declensions which exist in many languages.
If there isn't an equivalent for a paradigm in a certain inflection, you can instead just enter 'X' for that row so the mod knows there is no equivalent and then figure out what to do (this is only relevant during generation, at which point the mod will proceed to look for a pattern of the same gender but different number, then the same number but different gender).
Some words in certain languages might fall inside the patterns defined in the table, but actually be wrong! An example could be 'flor' from Spanish; it will be recognized as a masculine singular word, but is in fact feminine.
To deal with this, simply add these exceptions (which are also inflection patterns), using the actual inflection of the word as the key for the field under this subsection. In the 'flor' example it would be this:
<Exceptions>
FemSg: florThis section allows you to do stuff for specific items. Specifically, you can change the name for the item, and also specify its inflection, which might be useful if it's not already covered by the main table or by the <Exceptions> subsection. One example could be items whose name is an acronym for something else (from Vanilla: the PDA, SDMG, REK, etc.).
This section can take a single tag: the internal name of a mod that the items inside belong to. Note that this isn't needed in order to work with modded items: you can also specify the name of the modded item like this when declaring the subsections: ModInternalName/ItemInternalName, which is a pattern also used by the item chat tag in base tModLoader.
The structure for each item is quite simple: one subsection per item, where the subsection name is the internal name of that item. If you decide to put a tag on the subsection, that tag will be used to replace the name of that item.
You can declare three different fields under the subsection (depending on what you want). These fields are Gender, Number, and Inflection. The last one is simply an easy way to write both gender and number at the same time. These fields are used to change the inflection of the item, which affect how prefixes look.
Here's an example:
# If this section was instead [Items:CalamityMod], you wouldn't need to write the name of the mod in front of the item name later,
# but then every item inside would need to be from Calamity.
[Items]
# Let's work with the Photon Ripper from Calamity.
<CalamityMod/PhotonRipper:Photon Cuddler> # The tag changes the name of the Photon Ripper to Photon Cuddler while this file is active.
Gender: Fem
Number: Mn
# Or, could also use the shorthand:
# Inflection: FemMn
# Now let's change the SDMG's gender.
<SDMG>
Gender: NeutThis section is quite similar to the previous one, you can rename prefixes in the same way, specify the mod, etc. The only difference is with the fields that are available.
Instead of defining something's inflection, we can define specific forms per inflection for this prefix. This is useful for adjectives which are highly irregular and can't be accurately made using the main table.
Just to illustrate the point, let's say there's a prefix called Crazy in the game, which is '(Fou)' in French. This adjective is irregular, as it has a specific form for the feminine singular and plural, and it isn't covered by the main table. Here's how you could solve that:
[Prefixes]
<Crazy>
FemSg: (Folle)
FemPl: (Folles)I hope this was a good enough explanation, I believe I covered everything. If you're reading this, the wiki page for inflection patterns doesn't exist right now, but it'll be made soon. If you have any more questions, ask away in the Discord Server. Thanks!
Here's a couple things I already have planned for the future of working with inflection files.
- Smarter main table stuff, namely being able to assign patterns to just "
Plural:" and stuff like that, instead of having to write out each gender and number combo. This would allow me to chop off two whole rows from the Russian and Polish files I believe. - Work on being able to change inflection files and see the changes live, just like with localization files in tModLoader.
- I want to make making them even easier, so I might work on some Sublime Text plugin and/or VS/VSC plugin to do automatic formatting, error messsages, and autocomplete.
- There's a huge problem with the current table format: both nouns and adjectives are treated the same, which causes inaccuracy with certain languages. We should be able to remedy this by being able to split the table into
<Nouns>and<Adjectives>subsections. Current LPlus files will be treated as both (whatever that might mean).