(lang)
| 171 | } |
| 172 | |
| 173 | async function getTranslations(lang) { |
| 174 | let { result } = await request('/resource_translations', { |
| 175 | query: { |
| 176 | 'filter[resource]': RESOURCE_ID, |
| 177 | 'filter[language]': `l:${lang}`, |
| 178 | include: 'resource_string', |
| 179 | }, |
| 180 | }); |
| 181 | let { data, included } = result; |
| 182 | while (result.links.next) { |
| 183 | ({ result } = await request(result.links.next)); |
| 184 | data = data.concat(result.data); |
| 185 | included = included.concat(result.included); |
| 186 | } |
| 187 | const includedMap = included.reduce((prev, item) => { |
| 188 | prev[item.id] = item; |
| 189 | return prev; |
| 190 | }, {}); |
| 191 | data.forEach(item => { |
| 192 | Object.assign(item.relationships.resource_string.data, includedMap[item.relationships.resource_string.data.id]); |
| 193 | }); |
| 194 | return data; |
| 195 | } |
| 196 | |
| 197 | async function updateTranslations(updates) { |
| 198 | const { result } = await request('/resource_translations', { |
no test coverage detected