init static method

void init([
  1. String? configFileName
])

Initializes the language configuration.

configFileName is an optional parameter that specifies the name of the configuration file. If not provided, the default configuration file name ("lang_tr.yaml") will be used.

Implementation

static void init([String? configFileName]) {
  File configFile = File(configFileName ?? _configFileName);
  if (configFile.existsSync()) {
    String config = configFile.readAsStringSync();
    List<String> lines = config.split("\n");
    for (var line in lines) {
      if (line.contains("output_file:")) {
        outputDirName = line.split(":").last.trim();
      } else if (line.contains("lang_dir:")) {
        langDirName = line.split(":").last.trim();
      } else if (line.contains("default_lang:")) {
        defaultLang = line.split(":").last.trim();
      } else if (line.contains("current_lang:")) {
        currentLang = line.split(":").last.trim();
      }
    }
    if (currentLang.trim().isEmpty) {
      currentLang = defaultLang; // set default language
    }
  } else {
    printWarning(
        "Config ${configFile.path} file not found. Using default values.");
  }
}