How to use i18n within Fasty.ovh ?

Fasty.ovh allow you to deal with i18n texts easily. You have actually 2 ways to do it :

Managing multiple views

When you define a datatype, you can define if some fields are translatable or not. For that, you need to set the tr: true attribute to your json schema. You can have a look on the sample json below... ALl the fields with tr: true are translatable

{
  "model": [
    { "r": true, "c": "1-1", "n": "title", "t": "string", "j": "joi.string().required()", "l": "Title", "tr": true },
    { "r": true, "c": "1-1", "n": "color", "t": "string:color", "j": "joi.string().required()", "l": "Pick a color"},
    { "r": true, "c": "1-1", "n": "position", "t": "integer", "j": "joi.number().integer()", "l": "Position" },
    { "r": true, "c": "1-1", "n": "online", "t": "boolean", "j": "joi.number().integer()", "l": "Online?" },
    { "r": true, "c": "1-1", "n": "published_at", "t": "date", "j": "joi.date().format('YYYY-MM-DD').raw().required()", "l": "Published_at" },
    { "r": true, "c": "1-1", "n": "time", "t": "time", "j": "joi.string()", "l": "Time" },
    { "r": true, "c": "1-1", "n": "desc", "t": "text", "j": "joi.string()", "l": "Description" },
    {
      "r": true, "c": "1-1", "n": "author_key", "t": "list", "j": "joi.string()", "l": "User",
      "d": "d": "FOR doc IN datasets FILTER doc.type == 'authors' RETURN [doc._key, CONCAT(doc.ln, ' ', doc.fn)]"
    },
    { "r": true, "c": "1-1", "n": "image", "t": "image", "j": "joi.string()", "l": "Pictures" },
    { "r": true, "c": "1-1", "n": "file", "t": "file", "j": "joi.string()", "l": "Files" },
    {
      "r": true, "c": "1-1", "n": "tags", "t": "tags", "j": "joi.array()", "l": "Tags",
      "d": "LET tags = (FOR doc IN datasets FILTER doc.type=='books' AND doc.tags != NULL RETURN doc.tags) RETURN UNIQUE(FLATTEN(tags))"
    },
    { "r": true, "c": "1-1", "n": "items", "t": "multilist", "j": "joi.array()", "l": "Multi List of tags", "d": "AQL request" },
    { "r": true, "c": "1-1", "n": "position", "t": "map", "j": "joi.array()", "l": "Coordinates" },
    { "r": true, "c": "1-1", "n": "html", "t": "code:html", "j": "joi.any()", "l": "Some HTML" },
    { "r": true, "c": "1-1", "n": "scss", "t": "code:scss", "j": "joi.any()", "l": "Some SCSS" },
    { "r": true, "c": "1-1", "n": "javascript", "t": "code:javascript", "j": "joi.any()", "l": "Some JS" },
    { "r": true, "c": "1-1", "n": "json", "t": "code:json", "j": "joi.any()", "l": "Some Json" },
    { "r": true, "c": "1-1", "n": "content", "t": "html", "j": "joi.any()", "l": "Content Editor" }
  ],
  "columns": [
    { "name": "title", "tr": true, "class": "uk-text-right", "toggle": true,
      "values": { "true": "online", "false": "offline" },
      "truncate": 20, "uppercase": true, "lowercase": true
    }
  ],
  "act_as_tree": true,
  "revisions": 10,
  "publishable": true,
  "slug": ["title"],
  "sort": "SORT doc.order ASC",
  "search": ["title", "barcode", "desc"],
  "includes": {
    "conditions": "FOR c IN customers FILTER c._key == doc.customer_key",
    "merges": ", customer: c "
  },
  "timestamps": true
}

So to edit your content, just switch the lang using the links in the nav bar.

Using the {{ tr | keyword }} feature

When you use this shortcut, all you have to do is to replace you content by it and it will automatically create entries in the Trads page.

Have a look to this sample below :

<div class="col-md-7 col-12 pb-3">
	<div class="col-md-12 col-12 pl-0 pb-3 text-center">
	{{ tr | sur le même sujet }}
	<hr/>
	</div>
</div>

It will create an entry in trads page for the specified key.

So as a developer, it's very easy to manage your texts for i18n.

People in charge of the website content will be able to easily update translations.

It's easy, very fast and so powerful.


Leave a comment