#[non_exhaustive]pub enum FtlOutputOptions {
#[non_exhaustive] MultiFile {
output_ftl_folder: String,
},
#[non_exhaustive] SingleFile {
output_ftl_file: String,
compressor: Option<Box<dyn Fn(Vec<u8>) -> Result<Vec<u8>, Box<dyn Error>>>>,
},
}Expand description
The ftl output options for the build command. This allows you to configure how the output ftl files are generated, and also what type of access code is generated.
Build it with FtlOutputOptions::single_file,
FtlOutputOptions::single_compressed_file or
FtlOutputOptions::multi_file (the default is a single uncompressed file
at gen/translations.ftl).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
#[non_exhaustive]MultiFile
Generates FTL files as one file per language which means that individual resource files are appended into one file.
This is especially useful client-side when you don’t want to embed the files in the binary or download them all together.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]SingleFile
Generates FTL files as one file for all languages, which means that individual resource files are appended into one file.
This is preferred for when you embed the files in your binary which typically is done server-side and also client-side when the files are small enough to either embed in the binary or download in a html request.
Fields
This variant is marked as non-exhaustive
output_ftl_file: StringThe path to the where the output ftl file will be written. For convenience fluent-typed joins all ftl resources for each language into a single file.
Defaults to “gen/translations.ftl” in the root of the package.
compressor: Option<Box<dyn Fn(Vec<u8>) -> Result<Vec<u8>, Box<dyn Error>>>>The compresssor is an closure that takes the ftl file content as a byte array, compresses it and returns the compressed bytes.
Any compression algorithm can be used, but it’s up to the user to import the necessary crate and do the compression and when using it decompress in the same manner.
Implementations§
Source§impl FtlOutputOptions
impl FtlOutputOptions
Sourcepub fn single_file(file: &str) -> Self
pub fn single_file(file: &str) -> Self
All languages joined into one uncompressed .ftl file at file,
suitable for embedding in the binary (server-side) or a single download.
Sourcepub fn single_compressed_file<F>(file: &str, compressor: F) -> Self
pub fn single_compressed_file<F>(file: &str, compressor: F) -> Self
Like single_file, but the joined bytes are passed
through compressor before being written. You bring the compression
crate and must decompress the bytes the same way at load time.
Sourcepub fn multi_file(folder: &str) -> Self
pub fn multi_file(folder: &str) -> Self
One .ftl file per language written into folder, for loading a single
language on demand rather than embedding them all.