{"id":13609657,"url":"https://github.com/flavioarfaria/Catalog","last_synced_at":"2025-04-12T20:32:13.800Z","repository":{"id":61469563,"uuid":"491564487","full_name":"flavioarfaria/Catalog","owner":"flavioarfaria","description":"Generate type-safe, user-friendly extensions to resolve Android resources.","archived":false,"fork":false,"pushed_at":"2023-10-23T06:10:24.000Z","size":337,"stargazers_count":146,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-07T15:46:01.443Z","etag":null,"topics":["android","gradle-plugin","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flavioarfaria.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-05-12T15:13:37.000Z","updated_at":"2024-08-17T19:44:41.000Z","dependencies_parsed_at":"2023-02-01T08:45:59.542Z","dependency_job_id":"cc328fa7-b494-4a33-b7e8-c872500ed676","html_url":"https://github.com/flavioarfaria/Catalog","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flavioarfaria%2FCatalog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flavioarfaria%2FCatalog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flavioarfaria%2FCatalog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flavioarfaria%2FCatalog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flavioarfaria","download_url":"https://codeload.github.com/flavioarfaria/Catalog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248629904,"owners_count":21136341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","gradle-plugin","kotlin"],"created_at":"2024-08-01T19:01:36.883Z","updated_at":"2025-04-12T20:32:12.751Z","avatar_url":"https://github.com/flavioarfaria.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# Catalog\n\n_Just like View Binding, but for resources._\n\nCatalog is a Gradle plugin that generates type-safe, user-friendly extensions to resolve Android resources.\n\nLet's see how the following string resource gets resolved without and with Catalog:\n\n```xml\n\u003cstring name=\"good_morning_with_weather\"\u003eGood morning, %1$s! It’s %2$d°C outside.\u003c/string\u003e\n```\n\n### Without Catalog:\n\nAndroid resource resolution is overly verbose. It also uses snake case for resource identifiers,\nwhich diverts away from Java/Kotlin naming conventions. In addition, parametrized strings and\nplurals are not type safe. Android Studio comes with a very loose lint check for argument types,\nbut it treats all arguments as optional and it won't flag if you miss one.\n\nHere's how we resolve string resources without Catalog:\n\n\u003cimg width=\"644\" src=\"https://user-images.githubusercontent.com/1800351/201457373-cfae9625-1add-4e43-93ec-771c69efb406.png\"\u003e\n\n### With Catalog:\n\n\u003cimg width=\"725\" alt=\"image\" src=\"https://user-images.githubusercontent.com/1800351/203698324-cfb73cc8-dca2-4eda-8287-64ce74fa2367.png\"\u003e\n\nYou can also use Catalog to access the resource id directly:\n\n\u003cimg width=\"691\" alt=\"image\" src=\"https://user-images.githubusercontent.com/1800351/201457666-44ecff64-bc0e-4d55-9020-b1982fcfd331.png\"\u003e\n\nCatalog also works with plurals:\n\n```xml\n\u003cplurals name=\"unread_messages\"\u003e\n  \u003citem quantity=\"one\"\u003eYou have %1$d unread message\u003c/item\u003e\n  \u003citem quantity=\"other\"\u003eYou have %1$d unread messages\u003c/item\u003e\n\u003c/plurals\u003e\n```\n\n\u003cimg width=\"691\" alt=\"image\" src=\"https://user-images.githubusercontent.com/1800351/201458751-48d31e9a-d683-4006-80a3-2c7e9734e65d.png\"\u003e\n\nstring arrays:\n\n```xml\n\u003cstring-array name=\"seasons\"\u003e\n  \u003citem\u003eSpring\u003c/item\u003e\n  \u003citem\u003eSummer\u003c/item\u003e\n  \u003citem\u003eFall\u003c/item\u003e\n  \u003citem\u003eWinter\u003c/item\u003e\n\u003c/string-array\u003e\n```\n\n\u003cimg width=\"691\" alt=\"image\" src=\"https://user-images.githubusercontent.com/1800351/201458738-5c6d1b9b-af88-40fb-a3b9-730a140bfcdf.png\"\u003e\n\nand simple color resources:\n\n```xml\n\u003ccolor name=\"red\"\u003e#FFFF0000\u003c/color\u003e\n```\n\n\u003cimg width=\"689\" alt=\"image\" src=\"https://user-images.githubusercontent.com/1800351/219828664-70e5080b-ffff-43d9-91e6-4f254cfda855.png\"\u003e\n\nIn the future, other resource types like integer arrays, dimensions, etc. will also be supported.\n\n### Comment support\n\nResource comments are also carried over to extension properties and methods:\n\n```xml\n\u003c!-- This string resource is used in the launcher screen. --\u003e\n\u003cstring name=\"app_name\"\u003eCatalog\u003c/string\u003e\n```\n\n\u003cimg width=\"509\" src=\"https://user-images.githubusercontent.com/1800351/192677607-06a8d538-8786-4419-98df-21ad0cd4acd5.png\"\u003e\n\n### Compose support\n\nIf you're using compose, `@Composable` extensions will also be generated. In order to avoid\nsignature clashes, Compose extensions are extension methods of\n`com.flaviofaria.catalog.runtime.compose.[String, Plurals, StringArray]` whereas standard extensions\nare extension methods of `com.flaviofaria.catalog.runtime.resources.[String, Plurals, StringArray]`,\nso make sure you're importing the right class.\n\n\u003cimg width=\"650\" src=\"https://user-images.githubusercontent.com/1800351/201458064-9fff8e50-86fe-4d2c-8b7b-345ff7d87e81.png\"\u003e\n\n## How it works\n\nCatalog generates `Context` and `Fragment` extensions using [context receivers](https://blog.jetbrains.com/kotlin/2022/02/kotlin-1-6-20-m1-released/#prototype-of-context-receivers-for-kotlin-jvm).\n\n\u003cimg width=\"545\" alt=\"Screen Shot 2022-09-27 at 11 14 14 PM\" src=\"https://user-images.githubusercontent.com/1800351/192679242-be1b2d67-4b65-4e0a-a78a-14145f28dd47.png\"\u003e\n\nSince these extensions are `inline`, there will be no increase in your app method count or any\nsignificant impact on runtime performance.\n\n## Setup and configuration\n\nTo use Catalog, just apply the plugin to your module:\n\n```groovy\nplugins {\n  id 'com.flaviofaria.catalog' version '0.2.1'\n}\n```\n\nBy default, Catalog generates non-Compose extensions only. Compose extensions will also be generated\nif it detects Compose among your module dependencies. If your project is 100% written in Compose,\nyou can explicitly turn off non-Compose extensions by adding:\n\n```groovy\ncatalog {\n  generateResourcesExtensions = false\n}\n```\n\nSimilarly, you can also turn off Compose extensions:\n\n```groovy\ncatalog {\n  generateComposeExtensions = false\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflavioarfaria%2FCatalog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflavioarfaria%2FCatalog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflavioarfaria%2FCatalog/lists"}