Aptivi - Manual
ProjectsWebsiteBlog
Nitrocid KS v0.1.2 - Rolling Manual
Nitrocid KS v0.1.2 - Rolling Manual
  • Welcome!
  • Version Release Notes
  • Installation and Maintenance
    • Installing the Kernel
      • Windows
      • macOS
      • Linux
      • Android
    • Upgrading the Kernel
      • Windows
      • macOS
      • Linux
      • Android
    • Dependency Information
  • Fundamentals
    • What is the Kernel?
    • What is Nitrocid KS?
    • Simulated Kernel Features
      • Extra Features
        • More Networking
          • FTP Client
          • SSH Connection
          • SFTP Client
          • RSS Client
          • HTTP Client
          • Mail Client
        • Games and Amusements
          • Hangman
          • BackRace
          • Meteor
          • Pong
          • Russian Roulette
          • ShipDuet
          • Snaker
          • Solver
          • SpeedPress
          • Wordle
        • More Editors
          • JSON Editor
          • SQL Editor
        • Common Programs
          • Archive
          • Caffeine
          • Calendar
          • Calculator
          • Contacts
          • Dictionary
          • Git Shell
          • Notes
          • Stocks
          • Timers
          • To-do List
          • Unit Converter
          • Weather
        • Docking
        • Language Studio
        • Theme Studio
      • Accounts
        • Groups
        • Permissions
      • Editors
        • Text Editor
        • Hex Editor
      • Shells
        • Commands List
        • Addon Commands List
      • Files and Folders
        • Hashing and Encryption
      • The Nitrocid Homepage
      • Networking
      • Localization
      • Screensavers
      • Lockscreen Widgets
      • Audio Cues
  • Advanced and Power Users
    • Building the Kernel
      • Building on Windows
      • Building on macOS
      • Building on Linux
      • Building on Android
    • Kernel Modifications
      • Building your Mod
      • Analyzing your Mod
        • Text - NKS0001
        • ConsoleBase - NKS0002
        • ConsoleBase - NKS0003
        • ConsoleBase - NKS0004
        • ConsoleBase - NKS0005
        • ConsoleBase - NKS0006
        • ConsoleBase - NKS0007
        • ConsoleBase - NKS0008
        • ConsoleBase - NKS0009
        • Files - NKS0010
        • Files - NKS0011
        • Files - NKS0012
        • Files - NKS0013
        • Files - NKS0014
        • Files - NKS0015
        • Files - NKS0016
        • Files - NKS0017
        • Files - NKS0018
        • Files - NKS0019
        • Files - NKS0020
        • Files - NKS0021
        • Files - NKS0022
        • Files - NKS0023
        • Kernel - NKS0024
        • Kernel - NKS0025
        • Kernel - NKS0026
        • Kernel - NKS0027
        • Kernel - NKS0031
        • Kernel - NKS0032
        • Kernel - NKS0033
        • Kernel - NKS0037
        • Kernel - NKS0038
        • Kernel - NKS0039
        • Kernel - NKS0040
        • Kernel - NKS0041
        • Kernel - NKS0042
        • Kernel - NKS0043
        • Kernel - NKS0052
        • Kernel - NKS0053
        • Languages - NKS0044
        • Languages - NKS0045
        • Languages - NKS0046
        • Network - NKS0051
        • Text - NKS0047
        • Text - NKS0048
        • Text - NKS0049
        • Text - NKS0050
        • Text - NKS0054
        • Text - NKS0055
      • Managing your Mod
        • Inter-Mod Communication
        • Inter-Addon Communication
    • Diagnostics
      • Debugging
        • Local Debugging
        • Remote Debugging
      • Testing
      • Other Diagnostics
    • Bootloader
      • Boot Choices
      • Kernel Environments
      • Custom Boot Styles
    • Inner Workings
      • Kernel Settings
        • Mechanics of Settings App
        • Settings Format
        • Custom Settings
      • Shell Structure
        • Help System
        • Command Parsing
        • Command Information
        • Command Switches
        • Shell History
        • Shell Scripting
        • Shell Presets
        • Extra Shell Features
      • Multilingual Kernel
        • Locale Tools
        • Custom Languages
      • Inner Essentials
        • Kernel Drivers
          • Console Drivers
          • Debug Logger Drivers
          • Encoding Drivers
          • Encryption Drivers
          • Filesystem Drivers
          • Hardware Prober Drivers
          • Input Drivers
          • Network Drivers
          • RNG Drivers
          • Regular Expression Drivers
          • Sorting Drivers
        • Kernel Placeholders
        • The Permissions
        • The Users
        • Kernel Threads
        • Kernel Arguments
        • Kernel Journaling
        • Remote Procedure
        • Nitrocid Filesystem
        • Screensaver Internals
        • Splash Internals
        • Kernel Platform
        • Theme Internals
        • Color Internals
        • Privacy Consents
        • System Notifications
        • MAL and MOTD
        • Progress Handlers
        • Assembly Signing
        • Assembly Reflection
        • Random Number Generation
        • Network Tools
        • Date and Time
        • Mod Manual Pages
      • Miscellaneous APIs
  • Project Dependencies
  • Report an issue
  • Source code
  • API Reference
Powered by GitBook
On this page
  • JSON file format
  • Translation
  • LocalizedString struct
Edit on GitHub
  1. Advanced and Power Users
  2. Inner Workings

Multilingual Kernel

Describes about the inner workings of the kernel language feature

The languages were introduced to the kernel to allow users who don't natively speak English or prefer their native language to use the kernel. This page explains the inner workings of the multilingual kernel.

JSON file format

The kernel languages use the JSON localization files that store the following information:

  • Name: The name of the language

    • The type of this variable is a string

  • Transliterable: Whether the language contains the -T variant or not (transliterated vs. translated)

    • The type of this variable is a boolean

  • Localizations: Contains translated strings

    • The type of this variable is an array of strings

The source of the generated JSON files come from Nitrocid.Locales, a tool shipped with the kernel.

Translation

Before the translation process, the language manager needs to know what are the defined languages, including the custom ones. This processing is done by calling the LanguageManager.Languages property under the KS.Languages namespace.

The translation function, Translate.DoTranslation(), checks to see if the language exists by calling the above property and checking for the language key to see if it exists. If it's found, and the translation is needed (eng is not a current language), it calls the LanguageInfo version.

Finally, the overloaded function checks to see if the string is found within the translated strings. If it found one, it returns the translated string. Else, it surrounds the string with the (( and the )) signs to indicate that the locale data for this string is missing.

When the user is logged in, the kernel checks for preferred language value defined in the user configuration file.

If preferredlanguage is not defined, it'll fallback to the kernel language. Else, it uses the user preferred language.

To learn more about custom languages and how they work, click on the button below:

LocalizedString struct

The LocalizedString struct allows you to easily store both the original untranslated text and the localized translated text. You can easily create a new instance of this struct by casting it either implicitly or explicitly to a string.

// Implicit cast from the string
LocalizedString locStr1 = "Hello!";

// Explicit cast from the string
LocalizedString locStr2 = (LocalizedString)"Hello!";

// Using the constructor
LocalizedString locStr3 = new("Hello!");

The struct contains the following properties:

  • Original: The original string that was passed to the constructor

  • Localized: The string that is localized to the current language

You can get the localized string by either using the ToString() function, by getting the value of Localized property, or by casting the struct either implicitly or explicitly to a string.

// Using the ToString() function
string locStrRes1 = locStr1.ToString();

// Using the Localized property
string locStrRes2 = locStr1.Localized;

// Using implicit and explicit casting
string locStrRes3 = locStr1;
string locStrRes4 = (string)locStr1;

This is useful when defining variables that don't necessarily get regenerated dynamically. You should still use those variables to get the translated versions, given that those variables already provide fields or properties that use this struct.

Custom Languages