Giter Site home page Giter Site logo

i18n-cloud-sync's People

Contributors

evanburbidge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

i18n-cloud-sync's Issues

Restful API for localizations

Hi Evan,

Nice work. Hope it will make its way to a common standard for the community.

I would suggest to use a restful approach to treat data per domain as collections.

## Endpoints

GET `/health`
- will run a health check to see the server is running

GET `/locales`
- will return an overview of available locations
- `curl -i localhost:3000/locales`

\```json
{
  "locales": [
    {
      "id": "en", // e.g. ("en-UK", "pt-BR", "es-ES"),
      "links": {
        "self": "{domain}/locales/{id}", // where {id} would match the value above
        "s3": "{s3_domain_and_path}/{id}.json",
      }
    }
  ]
}
\```

GET `/locales/{id}`
- will return the assets available at that location
- `curl -i localhost:3000/locales/en -> {... some translations}`

\```json
{
  "locale": {
    "id": "en",
    "translations": {
      "App": {
        "hello": "Hello World"
      }
    }
  },
  "links": {
    "self": "{domain}/locales/{id}", // where {id} would match the value above
    "s3": "{s3_domain_and_path}/{id}.json",
  }
}
\```

POST `/locales`
- must includes a translations object in the body
- will update the given location with data passed into it via the request body
- `curl -d { "locale": { "id": "en", "translations": { "key": "translation" } } } -X POST localhost:3000/locales`
- status: `201 Created`

PATCH `/locales/{id}`
- will update configuration locations in your config file
- `curl -d { "id": "en", "translations": { "key": "some other value" } } -X PATCH localhost:3000/locales/en`
- status: `200 OK`

DELETE `/locales/{id}`
- not to be used very often only when removing or deprecating old translations
- `curl -X DELETE localhost:3000/locales/en`
- status: `204 No Content`

PATCH `/config/locales/{id}`
- will update specific configuration based on locale id
- `curl -d { "id": "en", "s3_domain":"s3://mycdn.com/" } -X PUT localhost:3000/config/locales/en`
- status: `200 OK`

PATCH `/config/locales`
- will update default configuration and it would fallback to this in case there is not specific config
- `curl -d { "s3_domain":"s3://mycdn.com/" } -X PUT localhost:3000/config/locales`
- status: `200 OK`

As you can see, PUT was gone from /locales due to be covered for PATCH updates. It does not mean, you need to remove PUT, I thought it would not be necessary and I might be wrong ;)

With it, we have 3 restful resources

  • /locales
  • /config/locales
  • /config

Each one with its own purpose. Please, you may have different goals/directions to evolve this project and, then, this suggestion wouldn't make sense.

I hope this help you though.

Nicely done again and keep up the good work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.