Module crowdin_api.api_resources.source_files.resource

Classes

class SourceFilesResource (requester: APIRequester, project_id: Optional[int] = None, page_size=25)

Resource for Source Files.

Source files are resources for translation. You can keep files structure using folders or manage different versions of the content via branches.

Use API to keep the source files up to date, check on file revisions, and manage project branches. Before adding source files to the project, upload each file to the Storage first.

Note: If you use branches, make sure your master branch is the first one you integrate with Crowdin.

Link to documentation: https://support.crowdin.com/developer/api/v2/#tag/Source-Files

Ancestors

Methods

def add_asset_reference(self, project_id: int, file_id: int, storage_id: int, name: str)
def add_branch(self, name: str, projectId: Optional[int] = None, title: Optional[str] = None, exportPattern: Optional[str] = None, priority: Optional[Priority] = None, isProtected: Optional[bool] = None)

Add Branch.

exportPattern and priority are for file-based projects only, isProtected is for string-based projects only.

Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.branches.post

def add_directory(self, name: str, projectId: Optional[int] = None, branchId: Optional[int] = None, directoryId: Optional[int] = None, title: Optional[str] = None, exportPattern: Optional[str] = None, priority: Optional[Priority] = None)
def add_file(self, storageId: int, name: str, projectId: Optional[int] = None, branchId: Optional[int] = None, directoryId: Optional[int] = None, title: Optional[str] = None, context: Optional[str] = None, type: Optional[FileType] = FileType.AUTO, importOptions: Union[SpreadsheetImportOptions, XmlImportOptions, WebXmlFileImportOptions, DocxFileImportOptions, VsdxFileImportOptions, IdmlFileImportOptions, HtmlFileImportOptions, HtmlWithFrontMatterFileImportOptions, MdFileImportOptions, MdxV1FileImportOptions, MdxV2FileImportOptions, StringCatalogFileImportOptions, AdocFileImportOptions, VdfFileImportOptions, OtherImportOptions, None] = None, exportOptions: Union[GeneralExportOptions, PropertyExportOptions, JavascriptExportOptions, MdFileExportOptions, MdxFileExportOptions, DocxFileExportOptions, None] = None, excludedTargetLanguages: Optional[Iterable[str]] = None, attachLabelIds: Optional[Iterable[int]] = None, parserVersion: Optional[int] = None, fields: Optional[Dict[str, Union[str, int, bool, Iterable[str]]]] = None)

Add File.

parserVersion must be used together with type. fields is Enterprise only.

Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.post

def check_branch_deletion_status(self, branchId: int, jobIdentifier: str, projectId: Optional[int] = None)
def check_directory_deletion_status(self, directoryId: int, jobIdentifier: str, projectId: Optional[int] = None)
def check_file_deletion_status(self, fileId: int, jobIdentifier: str, projectId: Optional[int] = None)
def delete_asset_reference(self, project_id: int, file_id: int, reference_id: int)
def delete_branch(self, branchId: int, projectId: Optional[int] = None, prefer: Optional[str] = None)

Delete Branch.

Pass prefer="respond-async" to delete the branch asynchronously (recommended); the API then returns a job to poll via check_branch_deletion_status.

Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.branches.delete

def delete_directory(self, directoryId: int, projectId: Optional[int] = None, prefer: Optional[str] = None)

Delete Directory.

Pass prefer="respond-async" to delete the directory asynchronously (recommended); the API then returns a job to poll via check_directory_deletion_status.

Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.directories.delete

def delete_file(self, fileId: int, projectId: Optional[int] = None, prefer: Optional[str] = None)

Delete File.

Pass prefer="respond-async" to delete the file asynchronously (recommended); the API then returns a job to poll via check_file_deletion_status.

Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.delete

def download_file(self, fileId: int, projectId: Optional[int] = None)
def download_file_preview(self, fileId: int, projectId: Optional[int] = None)
def edit_branch(self, branchId: int, data: Iterable[BranchPatchRequest], projectId: Optional[int] = None)

Edit Branch.

/exportPattern is for file-based projects only, /isProtected is for string-based projects only.

Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.branches.patch

def edit_directory(self, directoryId: int, data: Iterable[DirectoryPatchRequest], projectId: Optional[int] = None)
def edit_file(self, fileId: int, data: Iterable[FilePatchRequest], projectId: Optional[int] = None)

Edit File.

/fields and /fields/{fieldSlug} paths are Enterprise only. For /fields/{fieldSlug} pass the path as a string, e.g. "/fields/some-field".

Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.patch

def get_asset_reference(self, project_id: int, file_id: int, reference_id: int)
def get_asset_references_path(self, project_id: int, file_id: int, reference_id: Optional[int] = None)
def get_branch(self, branchId: int, projectId: Optional[int] = None)
def get_branch_path(self, projectId: int, branchId: Optional[int] = None)
def get_directory(self, directoryId: int, projectId: Optional[int] = None)
def get_directory_path(self, projectId: int, directoryId: Optional[int] = None)
def get_file(self, fileId: int, projectId: Optional[int] = None)
def get_file_path(self, projectId: int, fileId: Optional[int] = None)
def get_file_revision(self, fileId: int, revisionId: int, projectId: Optional[int] = None)
def get_file_revisions_path(self, projectId: int, fileId: int, revisionId: Optional[int] = None)
def list_asset_references(self, project_id: int, file_id: int, limit: Optional[int] = None, offset: Optional[int] = None)
def list_directories(self, projectId: Optional[int] = None, orderBy: Optional[Sorting] = None, branchId: Optional[int] = None, directoryId: Optional[int] = None, filter: Optional[str] = None, recursion=None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)
def list_file_revisions(self, fileId: int, projectId: Optional[int] = None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)
def list_files(self, projectId: Optional[int] = None, orderBy: Optional[Sorting] = None, branchId: Optional[int] = None, directoryId: Optional[int] = None, filter: Optional[str] = None, recursion: Any = None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)
def list_project_branches(self, projectId: Optional[int] = None, orderBy: Optional[Sorting] = None, name: Optional[str] = None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)
def restore_file(self, fileId: int, revisionId: int, projectId: Optional[int] = None)

Restore File.

Restore the file to one of the previous revisions.

Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.put

def search_branches(self, filter: str, projectIds: Optional[Iterable[int]] = None, userId: Optional[int] = None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)
def search_directories(self, filter: str, projectIds: Optional[Iterable[int]] = None, userId: Optional[int] = None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)
def search_files(self, filter: str, projectIds: Optional[Iterable[int]] = None, userId: Optional[int] = None, page: Optional[int] = None, offset: Optional[int] = None, limit: Optional[int] = None)
def update_file(self, fileId: int, storageId: int, projectId: Optional[int] = None, updateOption: Optional[FileUpdateOption] = None, importOptions: Union[SpreadsheetImportOptions, XmlImportOptions, WebXmlFileImportOptions, DocxFileImportOptions, VsdxFileImportOptions, IdmlFileImportOptions, HtmlFileImportOptions, HtmlWithFrontMatterFileImportOptions, MdFileImportOptions, MdxV1FileImportOptions, MdxV2FileImportOptions, StringCatalogFileImportOptions, AdocFileImportOptions, VdfFileImportOptions, OtherImportOptions, None] = None, exportOptions: Union[GeneralExportOptions, PropertyExportOptions, JavascriptExportOptions, MdFileExportOptions, MdxFileExportOptions, DocxFileExportOptions, None] = None, attachLabelIds: Optional[Iterable[int]] = None, detachLabelIds: Optional[Iterable[int]] = None, name: Optional[str] = None, replaceModifiedContext: Optional[bool] = None)

Update File.

Replace the file with a new one from the Storage. importOptions is sent to the API as-is (e.g. {"importTranslations": True} for spreadsheet files). Note that importOptions.importTranslations in the API response for spreadsheet files is marked as deprecated by the API and may not reflect the value sent in the request.

Link to documentation: https://support.crowdin.com/developer/api/v2/#operation/api.projects.files.put