Crate translocate

Crate translocate 

Source
Expand description

§libtranslocate converts a CSV translation file into multiple JSON translation files.

§Overview

CSV files are a convenient, and somewhat common format for housing translations. They are plain text files in the CSV format. The ease of exporting from an spreadsheet to CSV format makes it an ideal candidate for non-technical users to use for output in localization tasks. CSV files are also a supported import and export format for many localization services.

Unfortunately, though the format has been standardized there are many non well-formed CSV files in existence, making their direct use for web localization projects somewhat challenging. JSON meanwhile has a very strict format. It is also very popular—especially in web development—as a localization format.

This crate provides a binary, translocate which uses functions provided by libtranslocate to to read an input CSV localization file, and output JSON localization files, with one JSON file being generated for every localization that exists as a column in the input CSV file.

The format of the JSON files output are in the form { "localization-key": "localized text" } e.g.

{
  "app.title": "Translocate means to move from one place to another."
}

Structs§

CliArgs
Defines the command line arguments that the translocate binary will accepts.
Config
Configures how the CSV file will be read. Defaults are modified after parsing any provided command line options

Functions§

generate_json
Generate JSON files from CSV using structured deserialization
generate_json_fast
Generate JSON files from CSV using StringRecord
get_file_location
Takes a path argument and returns a representation of that file system location (PathBuf), or an io::Error if this representation can’t be created.
get_file_reader
Returns a configured CSV reader for the specified file, or an error.
run
Entry point for library to generate JSON translation files.