Skip to content

Add schema validation workflow #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/validate_schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Validate examples against schema

on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
schedule:
- cron: '0 0 * * 0' # weekly

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
- name: Validate JSON
uses: walbo/validate-json@6a48fa79d27775ab3099cb09cf1d8dfe5c4dcf11
with:
files: example/*.json
schema: schemas/arb.json
28 changes: 2 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,6 @@ In ARB, localizable resources are encoded as a JSON object. Each resource will h
**Example:**

```json
{
"@@locale": "en",
"@@context": "HomePage",
"helloAndWelcome": "Welcome {firstName} {lastName}!",
"@helloAndWelcome": {
"description": "Initial welcome message",
"placeholders": {
"firstName": {
"type": "String"
},
"lastName": {
"type": "String"
}
}
},
"newMessages": "You have {newMessages, plural, =0{No new messages} =1 {One new message} two{Two new Messages} other {{newMessages} new messages}}",
"@newMessages": {
"type": "text",
"description": "Number of new messages in inbox.",
"placeholders": {
"newMessages": {
"type": "int"
}
}
}
}
#TODO: add permalink to embed example in follow up PR
#https://github.com/google/app-resource-bundle/blob/111somehash111/example/simple.arb
```
47 changes: 27 additions & 20 deletions docs/specification.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@

# Application Resource Bundle Specification
* [Simple, extensible and directly usable](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#simple-extensible-and-directly-usable)
* [Sample resource file](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#sample-resource-file)
* [Resource Id](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#resource-id)
* [Resource Value](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#resource-value)
* [Placeholder in resource](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#placeholder-in-resource)
* [Plural and Gender support](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#plural-and-gender-support)
* [CSS resource](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#css-resource)
* [Resource attributes](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#resource-attributes)
* [Predefined resource attributes](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#predefined-resource-attributes)
* [Global attributes](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#global-attributes)
* [Customized attributes](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#customized-attributes)
* [Resource Linking](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#resource-linking)
* [Verbose and Compact versions of ARB](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#verbose-and-compact-versions-of-arb)
* [ARB namespace and registration](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#arb-namespace-and-registration)
* [Namespace reference with or without variation part](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#namespace-reference-with-or-without-variation-part)
* [ARB file organization](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#arb-file-organization)
* [Using ARB in](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#using-arb-in)
* [Using ARB in HTML](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#using-arb-in-html)
* [Common Mistakes when creating resource in ARB format](https://github.com/googlei18n/app-resource-bundle/wiki/ApplicationResourceBundleSpecification#common-mistakes-when-creating-resource-in-arb-format)
- [Application Resource Bundle Specification](#application-resource-bundle-specification)
- [Simple, extensible and directly usable](#simple-extensible-and-directly-usable)
- [Sample resource file](#sample-resource-file)
- [Resource Id](#resource-id)
- [Resource Value](#resource-value)
- [Placeholder in resource](#placeholder-in-resource)
- [Plural and Gender support](#plural-and-gender-support)
- [CSS resource](#css-resource)
- [Resource attributes](#resource-attributes)
- [Predefined resource attributes](#predefined-resource-attributes)
- [Global attributes](#global-attributes)
- [Customized attributes](#customized-attributes)
- [Resource Linking](#resource-linking)
- [Verbose and Compact versions of ARB](#verbose-and-compact-versions-of-arb)
- [ARB namespace and registration](#arb-namespace-and-registration)
- [ARB namespace](#arb-namespace)
- [Namespace reference with or without variation part](#namespace-reference-with-or-without-variation-part)
- [ARB file organization](#arb-file-organization)
- [Using ARB in JavaScript](#using-arb-in-javascript)
- [Manipulating ARB Instance](#manipulating-arb-instance)
- [Resource String in ARB](#resource-string-in-arb)
- [Using ARB in HTML](#using-arb-in-html)
- [Text in HTML](#text-in-html)
- [Image in HTML](#image-in-html)
- [CSS](#css)
- [Common Mistakes when creating resource in ARB format](#common-mistakes-when-creating-resource-in-arb-format)

## Simple, extensible and directly usable
Application Resource Bundle (abbr. ARB) is a localization resource format that is simple (based on JSON), extensible (vocabulary can be added without affecting existing tools and usage), and directly usable (applications can access the resource directly from this format without converting to another form).
Expand Down Expand Up @@ -421,4 +428,4 @@ CSS is handled the same way as other HTML element. A style element need to be pr
## Common Mistakes when creating resource in ARB format
* Invalid JSON format: the last item in a map/array should not be terminated by comma.
* Invalid JSON format: directional quotation marks (left quotation (“;U+201C) + right quotation (”;U+201D)) are used instead of non-directional quotation marks (";U+0022).
* Attribute not defined in ARB specification must be prefixed by `x-`
* Attribute not defined in ARB specification must be prefixed by `x-`
26 changes: 26 additions & 0 deletions example/simple.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"@@locale": "en",
"@@context": "HomePage",
"helloAndWelcome": "Welcome {firstName} {lastName}!",
"@helloAndWelcome": {
"description": "Initial welcome message",
"placeholders": {
"firstName": {
"type": "String"
},
"lastName": {
"type": "String"
}
}
},
"newMessages": "You have {newMessages, plural, =0{No new messages} =1 {One new message} two{Two new Messages} other {{newMessages} new messages}}",
"@newMessages": {
"type": "text",
"description": "Number of new messages in inbox.",
"placeholders": {
"newMessages": {
"type": "int"
}
}
}
}