Skip to content

KittyMac/laurette

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Laurette

Localization code generator written in vanilla C# with editor scripts for use in Unity3D. Laurette was heavily inspired by the awesome Laurine for Swift, and serves much of the same function for C#/Unity3D. Three cheers mate!

Why use Laurette?

Laurette automatically processes and then generates high performance C# code out of your projects .strings files. In your source code, you then reference the generate structures to access your localized content. If your .strings files change, the Laurette generated code will subsequently change and, if anything changes for the worse, your friendly compiler will let you know with errors exactly where they should be!

Laurette provides Unity editor scripts for seamless integration in Unity3D; just drop the two C# files (Laurette.cs and LauretteBuildProcess.cs) files into Assets/Editor. Laurette will monitor for any changes to .strings and .strings.txt files, and will immediately process them. By default, it will put the generated code in Assets/Localizations.cs.

Pretty examples pls!

Once Laurette has generated the Assets/Localizations.cs file, you can access the localizations from the Localizations static struct.

"MainMenu.PlayButton.Title" = "Play My Game!";

can now be accessed from code by:

buttonLabel.text = Localizations.MainMenu.PlayButton.Title;

Image : Autocomplete Variables

Laurette will also properly detect format strings, and provide built-in methods for them:

"GameOver.ScoreField.Title" = "You vanquished {0} {1}!";
gameOverField.text = Localizations.GameOver.ScoreField.Title (5, Localizations.Monsters.Goblins);

Image : Autocomplete Methods

Nested Structures

Laurette will generate nested structures for language keys which follow a dot-separated format. For example, the key "Monsters.Goblins" will generate the following code:

public struct Localizations {
	public enum LanguageCode {
		ru,
		en,
	}
	
	public struct Monsters {
		/// <summary>English: "Goblins"</summary>
		public static string Goblins {
			get {
				return Monsters_Goblins_[(int)currentLanguage];
			}
		}
	}
	
	static readonly string[] Monsters_Goblins_ = new string[] {
		"Goblins",
		"гоблины",
	};
}

Embedded Strings

There are dozens of different methods for localizing content in Unity3D; just search on the Asset Store. To make Laurette as lean, mean, and performant as possible, Laurette will compile the translated strings directly into the main Localizations structure. Translation lookups are then as quick as a single static string array access.

Directory Structure

Laurette supports a standard directory structure for .strings file placements; put the .strings files in a directory which is named the language code for that language. All of the languages found will be compiled into an enum called LanguageCode in the Localization structure.

Image : Directory Structure

##Licence

The MIT License (MIT)

Copyright (c) 2016 Rocco Bowling

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Laurette is a C#/Unity port of Laurine, a Localization code generator written for Swift.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages