The first developer-oriented translation tool. True asynchronous flow between translators and your team.
Go to file
Simon Prévost ae0df57dae
Add basic support for XLIFF 1.2 file format (#79)
![image](https://user-images.githubusercontent.com/464900/55203015-35c17980-51a0-11e9-8647-d91209c7b6de.png)

## Issue
📚 https://github.com/mirego/accent/issues/21

## Feature
This is a basic implementation of the XLIFF 1.2 format. This format is used heavily in a lot of translations related tool (and in XCode) so I may have missed some of the implementation details. But it’s a good start for someone who want to contribute to Accent 😉 

## Refactor
This format is a bit trickier than other since it required the master language to export the targets. We needed to refactor some module to use the master language in the serialization process. Also, not needed but cleaner, we wrap the document’s key `top_of_the_file_comment` and `header` inside a new struct `Language.Document`. This will become handy if we ever need to add an attribute to the document OR if we add a different attribute to the serialization input.

## Next steps
This format includes 2 new dependencies to handle XML encode and decode. _Why not use the same XML library used for the XML Android format?_ Because… \*drum roll\* The `<source>` XML tag when encoded by the `mochiweb_html` module is a self closing tag (per the HTML spec) 🥇 

Since those 2 new deps are required for the XLIFF format and can pretty print XML, we should use them _instead of `mochiweb`_ 🎉
2019-03-31 16:16:20 -04:00
cli Fix ci-check by rewriting lint and format under root package.json 2019-03-11 06:27:14 -04:00
config Add distillery and docker setup 2019-01-11 09:47:14 -05:00
jipt Fix ci-check by rewriting lint and format under root package.json 2019-03-11 06:27:14 -04:00
lib Add basic support for XLIFF 1.2 file format (#79) 2019-03-31 16:16:20 -04:00
priv Fix ci-check by rewriting lint and format under root package.json 2019-03-11 06:27:14 -04:00
rel Add distillery and docker setup 2019-01-11 09:47:14 -05:00
test Add basic support for XLIFF 1.2 file format (#79) 2019-03-31 16:16:20 -04:00
webapp Update emberjs to latest 2019-03-28 22:05:16 -04:00
.credo.exs Update deps and elixir/erlang version 2019-03-03 14:56:36 -05:00
.dockerignore Put back alpine 3.9 with libssl1.1 to fix crypto deps /usr/lib 2019-03-11 12:51:16 -04:00
.eslintignore Fix ci-check by rewriting lint and format under root package.json 2019-03-11 06:27:14 -04:00
.eslintrc Fix ci-check by rewriting lint and format under root package.json 2019-03-11 06:27:14 -04:00
.formatter.exs Refactor and adds credo env var check 2018-12-08 16:43:06 -05:00
.gitignore Fix ci-check by rewriting lint and format under root package.json 2019-03-11 06:27:14 -04:00
.prettierignore Update prettierignore and npm 2019-03-13 21:59:36 -04:00
.travis.yml Add root and subapp node_modules cache 2019-03-11 07:07:06 -04:00
app.json Add canonical host in app.json 2018-07-02 10:17:48 -04:00
Aptfile Initial commit 💥 2018-04-05 16:47:36 -04:00
CODE_OF_CONDUCT.md Initial commit 💥 2018-04-05 16:47:36 -04:00
compile Initial commit 💥 2018-04-05 16:47:36 -04:00
coveralls.json Fix coveralls merge 2019-01-11 09:48:09 -05:00
docker-compose.yml Use mirego/accent image if available else build in docker-compose 2019-03-13 08:34:17 -04:00
Dockerfile Remove useless dependencies 2019-03-13 08:32:43 -04:00
elixir_buildpack.config Update elixir buildpack config to install latest Elixir and Erlang 2019-03-13 20:54:13 -04:00
LICENSE.md Rename LICENSE to LICENSE.md 2018-05-05 14:11:28 -04:00
logo.svg Initial commit 💥 2018-04-05 16:47:36 -04:00
Makefile Fix ci-check by rewriting lint and format under root package.json 2019-03-11 06:27:14 -04:00
mix.exs Add basic support for XLIFF 1.2 file format (#79) 2019-03-31 16:16:20 -04:00
mix.lock Add basic support for XLIFF 1.2 file format (#79) 2019-03-31 16:16:20 -04:00
package-lock.json Fix version form colors 2019-03-13 08:34:17 -04:00
package.json Fix ci-check by rewriting lint and format under root package.json 2019-03-11 06:27:14 -04:00
phoenix_static_buildpack.config Fix phoenix_static_buildpack.config 2018-12-13 07:45:27 -05:00
Procfile Fix Procfile 2018-12-13 07:46:07 -05:00
README.md Fix travis badge in readme 2019-03-11 06:28:50 -04:00
tslint.json Fix ci-check by rewriting lint and format under root package.json 2019-03-11 06:27:14 -04:00


The first developer-oriented translation tool
True asynchronous flow between translators and your team.

WebsiteGraphiQL

Build Status Coverage Status Join the chat at https://gitter.im/mirego/accent

Accent provides a powerful abstraction around the process maintaining translations in a web/native app.

  • History. Full history control and actions rollback. Who did what, when.
  • UI. Simple yet powerful UI to enable translator and developer to be productive.
  • CLI. Command line tool to easily add Accent to your developer flow.
  • Collaboration. Centralize your discussions around translations.
  • GraphQL. The API that powers the UI is open and documented. Its easy to build a plugin/cli/library around Accent.

Contents

Section Description
🚧 Requirements Dependencies required to run Accent stack
🎛 Mix commands How to execute mix task with the Twelve-Factor pattern
🏎 Quickstart Steps to run the project, from API to webapp, with or without Docker
🌳 Environment variables Required and optional env var used
Tests How to run the extensive tests suite
🚀 Heroku Easy deployment setup with Heroku
🌎 Contribute How to contribute to this repo

🚧 Requirements

  • erlang ~> 21.2
  • elixir ~> 1.8
  • postgres >= 9.4
  • node.js >= 8.5.0
  • libyaml >= 0.1.7

🎛 Executing mix commands

The app is modeled with the Twelve-Factor App architecture, all configurations are stored in the environment.

When executing mix commands, you should always make sure that the required environment variables are present. You can source, use nv or a custom l33t bash script.

Every following steps assume you have this kind of system.

But Accent can be run with default environment variables if you have a PostgreSQL user named postgres listening on port 5432 on localhost.

Example

With nv you inject the environment keys in the context with:

$ nv .env mix <mix command>

🏎 Quickstart

This is the full development setup. To simply run the app, see the Docker instructions

  1. If you dont already have it, install nodejs with brew install nodejs
  2. If you dont already have it, install elixir with brew install elixir
  3. If you dont already have it, install libyaml with brew install libyaml
  4. If you dont already have it, install postgres with brew install postgres or the Docker setup as described below.
  5. Install dependencies with make dependencies
  6. Create and migrate your database with mix ecto.setup
  7. Start Phoenix endpoint with mix phx.server
  8. Start Ember server with npm run start --prefix webapp

Thats it!

Makefile

The Makefile should be the main entry for common tasks such as tests, linting, Docker, etc. This simplify the developpement process since you dont have to search for which service provides which command. mix, npm, prettier, docker, stylelint, etc are all used in the Makefile.

Docker

For the production setup, we use Docker to build an OTP release of the app. With docker-compose, you can run the image locally. Here are the steps to have a working app running locally with Docker:

When running the production env, you need to provide a valid GOOGLE_API_CLIENT_ID in the docker-compose.yml file.

  1. Run make build to build the OTP release with Docker
  2. Run make dev-start-postgresql to start an instance of Postgresql. The instance will run on port 5432 with the postgres user. You can change those values in the docker-compose.yml file.
  3. Run make dev-start-application to start the app! The release hook of the release will execute migrations and seeds before starting the webserver on port 4000 (again you can change the settings in docker-compose.yml)

Thats it! You now have a working Accent instance without installing Elixir or Node!

🌳 Environment variables

Accent provides a default value for every required environment variable. This means that with the right PostgreSQL setup, you can just run mix phx.server.

Variable Default Description
MIX_ENV dev The application environment (dev, prod, or test)
DATABASE_URL postgres://localhost/accent_development A valid database URL
CANONICAL_HOST localhost The host that will be used to build internal URLs
PORT 4000 A port to run the API on
WEBAPP_PORT 4200 A port to run the Webapp on (only used in dev environment)
API_HOST http://localhost:4000 The API host
API_WS_HOST ws://localhost:4000 The API Websocket host

Production setup

Variable Default Description
SENTRY_DSN none The secret Sentry DSN used to collect API runtime errors
WEBAPP_SENTRY_DSN none The public Sentry DSN used to collect Webapp runtime errors
GOOGLE_API_CLIENT_ID none When deploying in a prod environment, the Google login is the only way to authenticate user. In dev environment, a fake login provider is used so you dont have to setup a Google app.
RESTRICTED_DOMAIN none If specified, only authenticated users from this domain name will be able to create new projects.

Email setup

If you want to send emails, youll have to configure the following environment variables:

Variable Default Description
WEBAPP_EMAIL_HOST none The Web clients hostname. Used in the sent emails to link to the right URL.
MAILER_FROM none The email address used to send emails.
SMTP_ADDRESS none The SMTP server address you want to use to send your emails.
SMTP_PORT none The port ex: (25, 465, 587).
SMTP_USERNAME none The username for authentification.
SMTP_PASSWORD none The password for authentification.
SMTP_API_HEADER none An optional API header that will be added to sent emails.

Tests

API

Accent provides a default value for every required environment variable. This means that with the right PostgreSQL setup (and a few setup commands), you can just run mix test.

$ npm --prefix webapp run build
$ mix run ./priv/repo/seeds.exs
$ mix test

The full check that runs in the CI environment can be executed with ./priv/scripts/ci-check.sh.

🚀 Deploy on Heroku

An Heroku-compatible app.json makes it easy to deploy the application on Heroku.

Deploy on Heroku

🌎 Contribute

Before opening a pull request, please open an issue first.

Once youve made your additions and the test suite passes, go ahead and open a PR!

Dont forget to run the ./priv/scripts/ci-check.sh script to make sure that the CI build will pass :)

Contributors

License

Accent is © 2015-2018 Mirego and may be freely distributed under the New BSD license. See the LICENSE.md file.

About Mirego

Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. Were a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.

We also love open-source software and we try to give back to the community as much as we can.