After rework this exmaple 
[https://nim-lang.org/docs/tut2.html#building-your-first-macro-generating-source-code](https://nim-lang.org/docs/tut2.html#building-your-first-macro-generating-source-code)
    
    
    import macros, strutils
    
    var cfgFile = """title_ENh = Hubanize
    title_DKh = Hubanize
    title_ENc = Cx Manager
    title_DKc = Cx Manager
    help_ENh = Help
    help_DKh = Hjælp
    help_ENc = Help
    help_DKc = Hjælp"""
    
    let
        inputString = cfgFile
    
    macro readCfgAndBuildSource(cfgFilename: string): typed =
        let
            inputString = cfgFile
        var source = ""
        for line in inputString.splitLines:
            # Ignore empty lines
            if line.len < 1: continue
            var chunks = split(line, '=')
            if chunks.len != 2:
                error("Input needs '=' split values, got: " & line)
            source &= "const lng" & chunks[0].strip & "= \"" & chunks[1].strip 
& "\"\n"
        
        if source.len < 1: error("Input file empty!")
        result = parseStmt(source)
    
    readCfgAndBuildSource("languagefile.cfg")
    
    echo lnghelp_DKc
    

I hope it help you.

Reply via email to