I18NFivem 1.0.0

There is a newer version of this package available.
See the version list below for details.
Install-Package I18NFivem -Version 1.0.0
dotnet add package I18NFivem --version 1.0.0
<PackageReference Include="I18NFivem" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add I18NFivem --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: I18NFivem, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install I18NFivem as a Cake Addin
#addin nuget:?package=I18NFivem&version=1.0.0

// Install I18NFivem as a Cake Tool
#tool nuget:?package=I18NFivem&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

An Adaptation of https://github.com/xleon/I18N-Portable for Fivem!


Simple and cross platform internationalization/translations for Fivem

  • Client-Side ready
  • Simple to use: "key".Translate().
  • Simple and fluent initialization setup.
  • Readable locale files (.txt with key/value pairs).
  • Support for custom file formats (json, xml, etc)
  • Light weight
  • No dependencies.
  • Well tested

Setup locales

  • In your PCL/Core project, create a directory called "Locales".
  • Create a {languageCode}.txt file for each language you want to support. languageCode can be a two letter ISO code or a culture name like "en-US". See full list here.
  • Set "Build Action" to "Embedded Resource" on the properties of each file

Locale content sample

# key = value (the key will be the same across locales)
one = uno
two = dos
three = tres 
four = cuatro
five = cinco
# Enums are supported
Animals.Dog = Perro
Animals.Cat = Gato
Animals.Rat = Rata
Animals.Tiger = Tigre
Animals.Monkey = Mono
# Support for string.Format()
stars.count = Tienes {0} estrellas
TextWithLineBreakCharacters = Line One\nLine Two\r\nLine Three
Multiline = Line One
    Line Two
    Line Three

Other file formats (including custom) supported

Fluent initialization

    .SetNotFoundSymbol("$") // Optional: when a key is not found, it will appear as $key$ (defaults to "$")
    .SetFallbackLocale("en") // Optional but recommended: locale to load in case the system locale is not supported
    .SetThrowWhenKeyNotFound(true) // Optional: Throw an exception when keys are not found (recommended only for debugging)
    .SetLogger(text => Debug.WriteLine(text)) // action to output traces
    .SetResourcesFolder("OtherLocales") // Optional: The directory containing the resource files (defaults to "Locales")
    .Init(GetType().GetTypeInfo().Assembly); // assembly where locales live


string one = "one".Translate();
string notification = "Mailbox.Notification".Translate("Diego", 3); // same as string.Format(params). Output: Hello Diego, you've got 3 emails
string missingKey = "missing".Translate(); // if the key is not found the output will be $key$. Output: $missing$
string giveMeNull = "missing".TranslateOrNull(); // Output: null

string dog = Animals.Dog.Translate(); // translate enum value (Animals is an Enum backed up in the locale file with "Animals.Dog = Perro")

List<string> animals = I18N.Current.TranslateEnumToList<Animals>(); 

List<Tuple<Animals, string>> animals = I18N.Current.TranslateEnumToTupleList<Animals>();
string dog = animals[0].Item2; // Perro

Dictionary<Animals, string> animals = I18N.Current.TranslateEnumToDictionary<Animals>();
string dog = animals[Animals.Dog]; // Perro

// List of supported languages (present in the "Locales" folder) in case you need to show a picker list
List<PortableLanguage> languages = I18N.Current.Languages; // Each `PortableLanguage` has 2 strings: Locale and DisplayName

// change language on runtime
I18N.Current.Language = language; // instance of PortableLanguage

// change language on runtime (option 2)
I18N.Current.Locale = "fr";

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.4 204 7/31/2021
1.0.3 98 4/24/2021
1.0.2 94 4/24/2021
1.0.1 77 3/22/2021
1.0.0 65 3/22/2021