en-strings.stencil 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Temporary generated en files for enum Generation
  2. // Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
  3. // Source: https://github.com/SwiftGen/SwiftGen/discussions/1071#discussioncomment-7209188
  4. {% if files %}
  5. {% macro fileBlock file %}
  6. {% call documentBlock file file.document %}
  7. {% endmacro %}
  8. {# process the file #}
  9. {% macro documentBlock file document %}
  10. {% if document.metadata.type == "Dictionary" %}
  11. {% for key,value in document.metadata.properties %}
  12. {% call propertyBlock key value document.data %}
  13. {% endfor %}
  14. {% endif %}
  15. {% endmacro %}
  16. {# process the root dictionary #}
  17. {% macro propertyBlock key metadata data %}
  18. {% set propertyName %}{{key|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}{% endset %}
  19. {% if propertyName == "strings" %}
  20. {% for propertyKey in data[key] %}
  21. {% set propertyValue %}{{data[key][propertyKey].localizations.en.stringUnit.value}}{% endset %}
  22. {% set propertyPluralValue %}{{data[key][propertyKey].localizations.en.variations.plural.other.stringUnit.value}}{% endset %}
  23. {% if propertyValue %}
  24. "{{propertyKey}}" = "{{propertyValue}}";
  25. {% endif %}
  26. {% if propertyPluralValue %}
  27. "{{propertyKey}}" = "{{propertyPluralValue}}";
  28. {% endif %}
  29. {% endfor %}
  30. {% else %}
  31. {% endif %}
  32. {% endmacro %}
  33. {% if files.count > 1 or param.forceFileNameEnum %}
  34. {% for file in files %}
  35. {% filter indent:2," ",true %}{% call fileBlock file %}{% endfilter %}
  36. {% endfor %}
  37. {% else %}
  38. {% call fileBlock files.first %}
  39. {% endif %}
  40. {% else %}
  41. // No xcstring files found.
  42. {% endif %}