forked from patryksmolarz/braze-liquid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
connected-content-transifex.html
45 lines (41 loc) · 1.34 KB
/
connected-content-transifex.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{% comment %}Example of getting translated strings from Transifex. This example uses v2.5 of Transifex's API which will be deprecated 11/30/2022.{% endcomment %}
{% capture translation %}
{% assign project = 'example-project' %}
{% assign resource = 'example-resource' %}
{% if {{ ${language} }} == blank %}
{% assign userLanguage = {{ ${language} }} %}
{% else %}
{% assign userLanguage = 'en' %}
{% endif %}
{% connected_content
https://www.transifex.com/api/2/project/{{project}}/resource/{{resource}}/translation/{{userLanguage}}/strings?
:basic_auth transifex :content_type application/json
:save items %}
{% for item in items %}
{% case item.key %}
{% when 'deviceBlocked.string' %}
{% capture deviceBlocked %}
{% if item.translation != blank %}
{{ item.translation }}
{% else %}
{{ item.source_string }}
{% endif %}
{% endcapture %}
{% when 'deviceSuccess.string' %}
{% capture deviceSuccess %}
{% if item.translation != blank %}
{{ item.translation }}
{% else %}
{{ item.source_string }}
{% endif %}
{% endcapture %}
{% endcase %}
{% endfor %}
{% if deviceStatus == 'blocked' %}
{{ deviceBlocked | replace: '%%ipaddrr%%', ipaddrr | replace: '%%country%%', country | replace: '%%deviceName%%',
deviceName }}
{% else %}
{{ deviceSuccess }}
{% endif }
{% endcapture %}
{{ translation | strip }}