Difference between revisions of "HPL3/Language Configuration"

From Frictional Wiki
Jump to navigation Jump to search
m
Line 1: Line 1:
{{wip}}
 
 
 
{{shortPageTitle}}
 
{{shortPageTitle}}
When displaying any kind of text on the screen (For example, when picking up a note and reading it), the mod refers to a file in which that text information is stored in. That file is called a '''language file'''. Each language has their own language files. For example, if your mod has English and Czech translations, you will have separate English and Czech language files.
+
When displaying any kind of text on the screen (For example, when picking up a note and reading it), the mod refers to a file in which that text information is stored in. That file is called a '''language file'''. Each language has their own language files. For example, if your mod has English and Czech translations, you will have separate English and Czech language files.{{note|Not every mod requires a language file. Only if your mod has notes, messages, translations and so on, it should have its own language file.}}
  
{{note|Not every mod requires a language file. Only if your mod has notes, messages, translations and so on, it should have its own language file.}}
+
==Setting Up Language Files==
  
== Setting Up Language Files ==
+
When configuring a language for a mod, you need to have two separate files: a base language file, and a main language file. For example, if your mod has English and Czech languages, you will have 4 language files in total. A language file's extension ends with <code>.lang</code>
  
 +
The content of a language files is divided into '''categories''', each category holds language '''entries'''. A language entry holds the actual text information. The following is an example of a simple language file:<syntaxhighlight lang="xml">
 +
<LANGUAGE>
 +
      <MyLanguageCategory>
 +
          <Entry Name="HelloWorld">Hello World!</Entry>
 +
      </MyLanguageCategory>
 +
</LANGUAGE>
 +
</syntaxhighlight>
 +
{| class="wikitable"
 +
!Attribute
 +
!Description
 +
|-
 +
|LANGUAGE
 +
|Each language file begins and closes with a <code><LANGUAGE></code> tag.
 +
|-
 +
|MyLanguageCategory
 +
|A category named <code>MyLangaugeCategory</code>. You can name categories however you want, but if the name of the category is the same of an existing category in the main game's language file, that category will be overridden by yours.
 +
|-
 +
|Entry
 +
|A language entry tag. This holds the actual text information <code>Hello World!</code>
 +
|-
 +
|Name
 +
|The name of the entry. Each entry needs to have a name attribute so the game will be able to read the text from it.
 +
|}
 +
{{tip|Look at the structure of the main game's language files and try to mimic that in your own language file. There is no need to guess how to properly structure it if the main game already offers a solution for that.}}
 +
===Base Language File===
 +
The base language file holds text related to the main menu, key configuration, and general menu messages. It has a prefix <code>base_</code> in the name. For example, a base English language file will be named like this: <code>base_english.lang</code>.
  
=== Base Language File ===
+
'''The file should be located inside the mod's <code>config</code> folder, unless specified otherwise in the [[HPL3/Launch Configuration|Launch Configuration file]].'''
 +
{{Note|Unless you are going to have a custom menu, or going to add new input keys to your mod, there is no need for your mod to have a base language file.}}
  
{{note|Any category content that is placed inside your language file will override the category content of the main game's language file. If you do not need to change the content of a certain category in your language file, do not copy it.}}
+
===Main Language File===
 +
The main language file holds text related to in-game readables (such as notes), level names, game hints, item descriptions, etc. The name of file depends on the language it refers to. For example, an main English language file will be named like this: <code>english.lang</code>.
  
{{tip|Look at the structure of the main game's language files and try to mimic that in your own language file. There is no need to re-invent the wheel or guess how to properly structure it if the main game already offers a solution for that.}}
+
'''The file should be located inside the mod's <code>config/lang</code> folder, unless specified otherwise in the [[HPL3/Launch Configuration|Launch Configuration file]].'''
  
=== Main Language File ===
+
=== Overriding Existing Language File Categories ===
 +
{{note|Any category content that is placed inside your language file will override the category content of the main game's language file. If you do not need to change the content of a certain category in your language file, do not copy it.}}
  
 
[[Category:Modding]]
 
[[Category:Modding]]
 
[[Category:English]]
 
[[Category:English]]

Revision as of 14:41, 26 August 2020

When displaying any kind of text on the screen (For example, when picking up a note and reading it), the mod refers to a file in which that text information is stored in. That file is called a language file. Each language has their own language files. For example, if your mod has English and Czech translations, you will have separate English and Czech language files.

Note icon.png Not every mod requires a language file. Only if your mod has notes, messages, translations and so on, it should have its own language file.

Setting Up Language Files

When configuring a language for a mod, you need to have two separate files: a base language file, and a main language file. For example, if your mod has English and Czech languages, you will have 4 language files in total. A language file's extension ends with .lang

The content of a language files is divided into categories, each category holds language entries. A language entry holds the actual text information. The following is an example of a simple language file:

<LANGUAGE>
      <MyLanguageCategory>
           <Entry Name="HelloWorld">Hello World!</Entry>
      </MyLanguageCategory>
</LANGUAGE>
Attribute Description
LANGUAGE Each language file begins and closes with a <LANGUAGE> tag.
MyLanguageCategory A category named MyLangaugeCategory. You can name categories however you want, but if the name of the category is the same of an existing category in the main game's language file, that category will be overridden by yours.
Entry A language entry tag. This holds the actual text information Hello World!
Name The name of the entry. Each entry needs to have a name attribute so the game will be able to read the text from it.
Icon tip.png Tip: Look at the structure of the main game's language files and try to mimic that in your own language file. There is no need to guess how to properly structure it if the main game already offers a solution for that.

Base Language File

The base language file holds text related to the main menu, key configuration, and general menu messages. It has a prefix base_ in the name. For example, a base English language file will be named like this: base_english.lang.

The file should be located inside the mod's config folder, unless specified otherwise in the Launch Configuration file.

Note icon.png Unless you are going to have a custom menu, or going to add new input keys to your mod, there is no need for your mod to have a base language file.

Main Language File

The main language file holds text related to in-game readables (such as notes), level names, game hints, item descriptions, etc. The name of file depends on the language it refers to. For example, an main English language file will be named like this: english.lang.

The file should be located inside the mod's config/lang folder, unless specified otherwise in the Launch Configuration file.

Overriding Existing Language File Categories

Note icon.png Any category content that is placed inside your language file will override the category content of the main game's language file. If you do not need to change the content of a certain category in your language file, do not copy it.