0

Export to code repository

by
Published Oct 17, 2025

Export translations from Phrase Strings to repository provider according to the .phrase.yml file within the code repository. *Export 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
 * Export to code repository
8
 * Export translations from Phrase Strings to repository provider according to the
9
.phrase.yml file within the code repository.
10

11
*Export 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}/export`)
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