0

Import from code repository

by
Published Oct 17, 2025

Import translations from repository provider to Phrase Strings according to the .phrase.yml file within the code repository. _Import is done asynchronously and may take several seconds depending on the project size._

Script phrase Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Phrase = {
3
	token: string
4
	baseUrl: string
5
}
6
/**
7
 * Import from code repository
8
 * Import translations from repository provider to Phrase Strings according to the .phrase.yml file
9
within the code repository.
10

11
_Import is done asynchronously and may take several seconds depending on the project size._
12
 */
13
export async function main(auth: Phrase, account_id: string, id: string) {
14
	const url = new URL(`${auth.baseUrl}/accounts/${account_id}/repo_syncs/${id}/import`)
15

16
	const response = await fetch(url, {
17
		method: 'POST',
18
		headers: {
19
			Authorization: 'ApiToken ' + auth.token
20
		},
21
		body: undefined
22
	})
23
	if (!response.ok) {
24
		const text = await response.text()
25
		throw new Error(`${response.status} ${text}`)
26
	}
27
	return await response.json()
28
}
29