Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babelbox

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babelbox

A language localization generator for Minecraft

  • 2.1.2
  • PyPI
  • Socket score

Maintainers
1

Code style: black

Babelbox

Babelbox allows you to write your language files in .csv files and then generate Minecraft language.json files from them.
Creating translations in CSV gives you an easy overview over any errors or missing translations.

Installation

$ pip install babelbox

Usage

Reads translations from all sources and then generates minecraft language files for all language codes

$ # Single .csv file source
$ babelbox <file.csv>
$ # Directory containing .csv files as source
$ babelbox <directory>
$ # Multiple sources require output directory
$ babelbox <file1.csv> <directory> <file2.csv> -o <output_dir>

All options:

$ babelbox SOURCES...
    -o, --out                   The output directory of the generated files
    -p, --prefix-identifiers    Prefix identifiers with their path relative
                                to their SOURCES entry
    --dialect [excel|excel-tab|unix]
                                CSV dialect used to parse CSV. Dialect will
                                be automatically detected of omitted
    -d, --delimiter             CSV delimiter overwrite
    --quotechar                 CSV quote char overwrite
    -m, --minify                Minify generated files
    -i, --indent                Indentation used when generating files
    --dry                       Dry run. Don not generate any files
    -v, --verbose               Increase verbosity
    -q, --quiet                 Only output errors

Getting started

Single file source:

We have one .csv file containing translations:

resourcepack
  ⠇
  └╴lang
    └╴ items.csv
Itemen_usde_de
item.stick.namestickStock
# You can create comments like this
item.snowball.namesnowballSchneeball

Passing items.csv as a source to babelbox generates the language files en_us.json and de_de.json:

$ babelbox resourcepack/.../lang/items.csv
en_us.json
{
    "item.stick.name": "stick",
    "item.snowball.name": "snowball",
}

de_de.json
{
    "item.stick.name": "Stock",
    "item.snowball.name": "Schneeball",
}
resourcepack
  ⠇
  └╴lang
    ├╴ items.csv
    ├╴ en_us.json
    └╴ de_de.json

Directory source

We have two .csv files containing translations:

resourcepack
  ⠇
  └╴lang
    ├╴ items.csv
    └╴ blocks.csv

items.csv

Itemen_usde_de
item.stick.namestickStock

blocks.csv

Blocken_usde_de
block.log.namelogHolzstamm

Passing the lang directory as a source to babelbox generates the language files en_us.json and de_de.json:

$ babelbox resourcepack/.../lang
en_us.json
{
    "item.stick.name": "stick",
    "block.log.name": "log",
}

de_de.json
{
    "item.stick.name": "Stock",
    "block.log.name": "Holzstamm",
}
resourcepack
  ⠇
  └╴lang
    ├╴ items.csv
    ├╴ blocks.csv
    ├╴ en_us.json
    └╴ de_de.json

Shorten variable names:

We can use the --prefix-identifiers flag to save ourselve some typing. If all identifiers share a common prefix, we can name the file to that prefix and let Babelbox prepend it.

resourcepack
  ⠇
  └╴lang
    └╴ item.swords.csv
Swordsen_usde_de
diamond.nameDiamond SwordDiamantschwert
gold.nameGold swordGoldschwert
$ babelbox resourcepack/.../lang --prefix-identifiers
$ # Or abbreviated
$ babelbox resourcepack/.../lang -p
en_us.json
{
    "item.swords.diamond.name": "Diamond Sword",
    "item.swords.gold.name": "Gold sword",
}

de_de.json
{
    "item.swords.diamond.name": "Diamantschwert",
    "item.swords.gold.name": "Goldschwert",
}

All identifiers have been prefixed with item.swords.

Organize translations in folders

We can save ourselves even more typing and organize our translations files in a directory structure:

resourcepack
  ⠇
  └╴lang
    ├╴ item
    │  └╴ swords.csv
    └╴ block
      └╴ heavy.csv

swords.csv

Swordsen_usde_de
gold.nameGold swordGoldschwert

heavy.csv

Heavy Blocksen_usde_de
lead.nameLead BlockBleiblock
$ babelbox resourcepack/.../lang -p
en_us.json
{
    "item.swords.gold.name": "Gold sword",
    "block.heavy.lead.name": "Lead Block",
}

de_de.json
{
    "item.swords.gold.name": "Goldschwert",
    "block.heavy.lead.name": "Bleiblock",
}
resourcepack
  ⠇
  └╴lang
    ├╴ item
    │  └╴ swords.csv
    ├╴ block
    │   └╴ heavy.csv
    ├╴ en_us.json
    └╴ de_de.json

Beet plugin

Babelbox can be used as a beet plugin. Here is a example beet project using babelbox:

beet.json
resourcepack
  ⠇
  └╴lang
    └╴item.swords.csv

swords.csv

Swordsen_usde_de
gold.nameGold swordGoldschwert

beet.json

{
  "output": "build",
  "resource_pack": {
    "load": ["resourcepack"]
  },
  "pipeline": [
      "babelbox.integration.beet"
  ],
  "meta": {
      "babelbox": {
          "load": ["resourcepack/assets/minecraft/lang"],
          "prefix_identifiers": true
      }
  }
}

Running beet build generates the language files:

beet.json
resourcepack
  ⠇
  └╴lang
    └╴item.swords.csv
build
  ⠇
  └╴lang
    ├╴en_us.json
    └╴de_de.json

Contributing

Contributions are welcome. Make sure to first open an issue discussing the problem or the new feature before creating a pull request. The project uses poetry. Setup dev environment with invoke:

$ invoke install

Run tests:

$ invoke test

The project follows black codestyle. Import statements are sorted with isort. Code formatting and type checking is enforced using pre-commit

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc