Skip to content

[VIC3/CK3] Support special localizations #137

Description

@kaiser-chris

Hi @DragonKnightOfBreeze,

I thought about splitting out this from #109 since it touches another aspect than the GUI files.
Also these are heavily used in localizations as well.

I don't know whether you want to split this ticket further but I have three sections:

  • Localization Commands
  • Localization Formatting
  • Text Icons

Localization Commands

Victoria 3 and Crusader Kings 3 support parameterized commands in localizations.
Those can currently not be defined using CWT, so an extension would be needed.
These commands are case sensitive.

Examples

Supported Example

I haven't defined those yet, but I think these can be defined using the existing CWT syntax.

 gg_character_experience_master_tooltip: "[Character.GetFullName] is a #v $gg_character_experience_master$#! and has reached the top of their field."

Simple Example

Here a script value is retrieved from the top scope by its name.

building_requirement_low_mana_density: "To build this [concept_building] a state needs to have a [concept_mana_density] of at least [TopScope.ScriptValue('low_mana_density_threshhold')]."

Complex Example

In this example it uses multiple functions to decide which localizations to show and also uses a lot of formatting tags #.

 gg_character_tooltip: "[AddTextIf( Character.IsHistorical, Concatenate( Localize( 'DATA_CHARACTER_TOOLTIP_HISTORICAL' ), '\n\n' ) )][AddTextIf( Character.IsBusy, Concatenate( Localize( 'CHARACTER_IS_BUSY' ), '\n' ) )][Concept('concept_character_role', '$concept_character_roles$')]: [Character.GetAllRoleNames|v][ConcatIfNeitherEmpty(' #v and#! ', AddLocalizationIf(Character.MakeScope.Var('is_magic_researcher').IsSet, 'gg_character_role_researcher'))]$DATA_CHARACTER_NAME_TOOLTIP_COMMANDER_DETAILS$[ConcatIfNeitherEmpty('\n', AddLocalizationIf( Character.IsAgitator, 'AGITATOR_POLITICAL_MOVEMENT_IN_COUNTRY'))]\n\n[Concept('concept_character_trait', '$concept_character_traits$')]: [Character.GetTraitsDesc]\n[concept_interest_group]: [Character.GetInterestGroup.GetName]\n[concept_ideology]: [Character.GetIdeology.GetName]\n\n[SelectLocalization(Character.IsInExilePool, 'DATA_CHARACTER_NAME_TOOLTIP_LOCATION_EXILE', 'DATA_CHARACTER_NAME_TOOLTIP_LOCATION_COUNTRY')][ConcatIfNeitherEmpty('\n', AddLocalizationIf(Character.IsAgitator, 'EXILE_HOME_COUNTRY'))]\n[concept_culture]: [Character.GetCulture.GetName]\n[concept_religion]: [Character.GetReligion.GetName]\n[concept_popularity]: #tooltippable_name #tooltip:[Character.GetTooltipTag],POPULARITY_BREAKDOWN [LabelingHelper.GetLabelForPopularityCFixedPoint(Character.GetPopularity)]#!#! (#tooltippable #tooltip:[Character.GetTooltipTag],POPULARITY_BREAKDOWN [Character.GetPopularity|0]#!#!)\nAge: [Character.GetAge|v]"

Localization Formatting

Victoria 3 and Crusader Kings 3 support formatting tags in their localizations.
These are defined in gui/textformatting.gui in a way that could be parsed using existing CWT syntax.

How do they work

The tags are always started with #{tag_name}{space} and ended with #!.
Text between those is formatted using the tag name. The space after the tag name is NOT added into the final localization and only serves as a separator between the tag and text.

Definition Example

textformatting = {
	### VARIABLE
	format = {
		name = variable
		format = "white;bold;shadow"
	}
	format = {
		name = V
		format = "variable"
	}
}

Simple Example

In this example the Right Mouse Button and Mouse Wheel text is formatted as variables which means they are bold.

 gg_panel_map_drag_hint: "You can drag the map with the #v Right Mouse Button#!\nAnd zoom with the #v Mouse Wheel#!"

Insensitve Tag Example

The formatting tags are case insensitive.

 gg_technology_no_researcher_blink: "#BOLD Hire a New Researcher#!"

Stacking Tags Example

Those tags can be "stacked" to format a text in two or more differnt ways like HTML tags.

 gg_magic_technology_tooltip_requirements_done: "#darker_white #italic You have researched all required technologies#!#!"

Text Icons

Victoria 3 and Crusader Kings 3 support text icons in text. Text icons are referenced by using @{icon_name}!.
The base game icons are defined in gui/texticons.gui in a way that could be parsed using existing CWT syntax.
There can be multiple files containing text icons. In my mod additional text icons are defined in gui/gate_texticons.gui

Definition Example

texticon = {
	icon = magic_innovation
	iconsize = {
		texture = "gfx/interface/icons/generic_icons/gate_magic_innovation.dds"
		offset = { 0 20 }
		fontsize = 120
	}
}

Usage Example

 gg_magic_technology_tooltip_cost: "#title Cost:#! @magic_innovation! "

Concepts

Concepts can be referenced in two ways. Either directly [concept_name] or under a different name using a command [Concept('concept_name', '$other_loc_key$')].

Usage Examples

 gg_magic_countries: "Countries with [concept_magic_knowledge]"
 concept_gate_mana_well_desc: "A mana well is a tap on a [Concept('concept_gate_ley_lines','$concept_gate_ley_line$')]. Mana wells can produce an almost unlimited amount of $mana$.\n\nBut they can lead #v instability#! in the local [Concept('concept_gate_ley_lines','$concept_gate_ley_line$')], which may lead to #v accidents#!."

Values

Values also support formatting tags using a | separator. They allow a list of possible tags as well as Localization Formatting tags.

Base Formatting Tags

Code Effect
* Converts the variable to SI units—appends "K" or "M" and divides the variable appropriately, such as 65 536 becoming 65.53K and 1 500 000 becoming 1.50M. Displays 2 decimals after the dot by default.
^ Same as *.
= Prefixes the variable with + if the value is positive or - if it is negative.
0..9 Controls the number of decimals to display. Due to the nature of the game's variables, there are no more than 3 decimals that can be shown. Using any digit greater than 3 will instead have the same result as 3.
% Converts the variable to percentage, multiplying by 100 and appending a %. By default, will show 2 digits after the decimal point, though the second digit will always be 0.
%% Appends a percentage to the end of the variable without multiplying by 100.
+ Colours the variable green if positive, yellow if zero, red if negative.
- Colours the variable red if positive, yellow if zero, green if negative.

Usage Examples

This example defines the value as a modifier = (a plus in front of the string if it is positive or minus if it is negative), as a positive value (green when bigger than zero and red when it is below zero) + and the whole value is cut down to 0 commas so it is shown as an integer.

 effect_add_magic_innovation: "Add [SCOPE.GetValue('added_innovation')|+=0] [concept_magic_innovation]"

This example simply shows the variable as an int (0 values behind the comma) and formats it as a variable v which is basically equivalent to surrounding it with a text formatting tag like this: #v 1#!

 expedition_small_tooltip: "Starts preparation for an expedition which requires [SCOPE.ScriptValue('expedition_cost_small')|0v] $expedition_goods$."

Regards,

Chris

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

config-systemInvolves the plugin's config systemenhancementNew feature or requestlanguage-constructsSupport for various language constructs (e.g., complex expressions)

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions