Generates fictional town names for different locales.
Derived from OpenTTD's town name generator.
This can be used in a web page (via JavaScript), or from the command line (using Neko, but potentially other targets would work).
Click here to open the demo site.
- Any name algorithms that just randomly picked from a list of real names were omitted.
- Any name algorithms that used a real name, and could potentially produce the real name without embelishment, were modified so that the "real" component was omitted.
- The random number generator uses the Mersenne Twister algorithm.
The command line tool has been tested using Neko, however, other Haxe targets should work.
First, build the command line tool.
haxe cli.hxml
Run the tool like so (assuming you are in the "bin" directory):
neko townnamegen.n
or
neko townnamegen.n --locale Silly --num 200 --seed 1234567
--help
- Shows the help text
--list-locales
- Lists all the available options for the "locale" setting.
--locale <locale-key>
- (Optional) The town name locale. Defaults to "AdditionalEnglish".
--num <in-num>
- (Optional) The number of names to generate. Must be between 1 and 10,000. Defaults to 1.
--seed <seed>
- (Optional) The seed for the random number generator. Defaults to the current timestamp.
First, build the demo HTML and JS.
haxe demo.hxml
Then open bin/index.html in a web browser.
The name generator function is called like so:
var locale = 'AdditionalEnglish';
var num = 10;
var seed = 1234567; // or null
var results : Array<String> = townnamegen.TownNameGen.generate(locale, num, seed);
Locales can be added dynamically at compile-time. Merely implement the ILocale interface, optionally extending the BaseLocale class, and recompile, making sure to include your locale's package in your HXML. For example:
--macro include('mypackage.locales')
- Port the remaining locales from OpenTTD
- Polish
- Czech
- Norwegian
- Hungarian
- Danish
- Turkish
- Italian
- Catalan
TownNameGen is license under GPLv2, the same as OpenTTD.