import Foundation

{% macro render_entries(entries, indent, table_name) -%}
{% for entry in entries -%}
{% if entry.kind == "namespace" -%}
{{ indent }}{{ access_level }} enum {{ entry.swiftIdentifier }} {
{{ render_entries(entry.children, indent ~ "    ", table_name) }}{{ indent }}}
{% elif entry.kind == "string" -%}
{{ indent }}{{ access_level }} static let {{ entry.swiftIdentifier | lower_first }} = tr({{ table_name | string_literal }}, {{ entry.properties.key | string_literal }})
{% endif -%}
{% endfor -%}
{%- endmacro %}

{{ access_level }} enum {{ job.swiftIdentifier }} {
{%- for module in modules %}
    {{ access_level }} enum {{ module.name }} {
{{ render_entries(module.entries, "        ", module.properties.tableName) }}    }
{%- endfor %}
}

private func tr(_ table: String, _ key: String) -> String {
    NSLocalizedString(key, tableName: table, bundle: .main, value: "", comment: "")
}
