Blyx Nest Blyx language
Registry / Framework
framework · v0.1.2

Translation Memory

Associate one segment revision with a translation candidate and reject stale approval after source edits.

Source repository · Package JSON

Use Translation Memory

use vendor::translation_memory::translation_memory;

Run the example

nest demo translation_memory@0.1.2
blyxc native-run translation_memory-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::translation_memory::translation_memory;

fn main() {
    let arguments = cli_args();
    if args_len(arguments) > 0 {
        if args_len(arguments) % 2 != 0 {
            stderr_line("Expected event and value pairs");
            process_exit(2);
        }
        let mut live = translation_memory_start();
        let mut i = 0;
        while i < args_len(arguments) {
            let input = args_at(arguments, i + 1);
            if !text_is_number(input) {
                stderr_line("Expected a whole numeric event value");
                process_exit(2);
            }
            live = translation_memory_step(live, args_at(arguments, i), text_number(input));
            let command = translation_memory_command(live);
            println!(command);
            if command == "reject" { process_exit(1); }
            i += 2;
        }
        return;
    }
    let mut state = translation_memory_start();
    state = translation_memory_step(state, "source", 4.0);
    println!(translation_memory_command(state));
    state = translation_memory_step(state, "hit", 4.0);
    println!(translation_memory_command(state));
    state = translation_memory_step(state, "edit", 5.0);
    println!(translation_memory_command(state));
    state = translation_memory_step(state, "miss", 0.0);
    println!(translation_memory_command(state));
    state = translation_memory_step(state, "ready", 5.0);
    println!(translation_memory_command(state));
    state = translation_memory_step(state, "accept", 5.0);
    println!(translation_memory_command(state));
}

Expected output

find_match
present_match
invalidate_candidate
request_translation
present_draft
store_translation

Published versions

VersionPackageSource commitSHA-256
0.1.2Download ZIP · Browse files6eca4c018fa6983a93e1ad63b9a7d0e1cf0301de55a691f8be837082b979bd6a07c40fe017
0.1.1Download ZIP · Browse files0f8b6fa81bc37597cd74c745a812e43227c5de931f283c1f103877e3df83cd4f13bd6056d0
0.1.0Download ZIP · Browse files6349f23784152b306c9aa71736fc87f0664d5c5452f8aba3fad386ea0e4a3ef0850aa8365a