BuildFile
Represent the state of a translatable file during the build process.
Attributes
| Attribute | Type | Description |
|---|---|---|
| command | [Command](../testserver/command.md?sid=django_core_management_commands_testserver_command) | The command instance responsible for managing the current translation build process. |
| domain | string | The translation domain, such as 'django' or 'djangojs', used to determine how the file is processed. |
| translatable | [TranslatableFile](translatablefile.md?sid=django_core_management_commands_makemessages_translatablefile) | An object representing the source file metadata, including its original path and filename. |
| is_templatized | boolean | Indicates whether the file requires preprocessing based on its domain and file extension. |
| path | string | The filesystem path to the original translatable source file. |
| work_path | string | Path to a file which is being fed into GNU gettext pipeline. This may be either a translatable or its preprocessed version. |
Constructor
Signature
def BuildFile(
command: Any,
domain: str,
translatable: Any
)
Parameters
| Name | Type | Description |
|---|---|---|
| command | Any | The command associated with the build process. |
| domain | str | The translation domain (e.g., 'django'). |
| translatable | Any | The translatable file object containing path and file information. |
Methods
is_templatized()
@classmethod
def is_templatized() - > boolean
Determines if the file requires template processing based on its domain and file extension.
Returns
| Type | Description |
|---|---|
boolean | True if the file is a Django template (non-Python file), False otherwise |
path()
@classmethod
def path() - > string
Retrieves the original filesystem path of the translatable file.
Returns
| Type | Description |
|---|---|
string | The absolute or relative path to the source translatable file |
work_path()
@classmethod
def work_path() - > string
Path to a file which is being fed into GNU gettext pipeline. This may be either a translatable or its preprocessed version.
Returns
| Type | Description |
|---|---|
string | The filesystem path used during the extraction process, pointing to either the original file or a generated .py version |
preprocess()
@classmethod
def preprocess()
Preprocess (if necessary) a translatable file before passing it to xgettext GNU gettext utility.
postprocess_messages()
@classmethod
def postprocess_messages(
msgs: string
) - > string
Postprocess messages generated by xgettext GNU gettext utility. Transform paths as if these messages were generated from original translatable files rather than from preprocessed versions.
Parameters
| Name | Type | Description |
|---|---|---|
| msgs | string | The raw message string output from the xgettext utility containing file location comments |
Returns
| Type | Description |
|---|---|
string | The modified message string with file references updated to point to the original source files |
cleanup()
@classmethod
def cleanup()
Remove a preprocessed copy of a translatable file (if any).