Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial i18n implementation #14

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions .tx/config
@@ -0,0 +1,10 @@
[main]
host = https://www.transifex.com

[silverstripe-elemental-filelist.en-yml]
file_filter = lang/<lang>.yml
minimum_perc = 0
source_file = lang/en.yml
source_lang = en
type = YAML_GENERIC

6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -34,6 +34,12 @@ Elemental FileList Block will add the following Element to your site:

The FileList Element will display a list of files for download.

## Translations

The translations for this project are managed via [Transifex](https://www.transifex.com/dynamicagency/silverstripe-elemental-filelist/)
and are updated automatically during the release process. To contribute, please head to the link above and get
translating!

## Maintainers

* [Dynamic](http://www.dynamicagency.com) (<dev@dynamicagency.com>)
Expand Down
Empty file added lang/_manifest_exclude
Empty file.
17 changes: 17 additions & 0 deletions lang/en.yml
@@ -0,0 +1,17 @@
en:
Dynamic\Elements\FileList\Elements\ElementFileList:
FilesLabel: 'Files'
PLURALNAME: 'File List Elements'
PLURALS:
one: 'A File List'
other: '{count} File Lists'
SINGULARNAME: 'File List Element'
Dynamic\Elements\FileList\Model\FileListObject:
FileLabel: 'File'
FileNameLabel: 'File'
PLURALNAME: 'Files'
PLURALS:
one: 'A File'
other: '{count} Files'
SINGULARNAME: 'File'
TitleLabel: 'Title'
23 changes: 13 additions & 10 deletions src/Elements/ElementFileList.php
Expand Up @@ -18,16 +18,6 @@ class ElementFileList extends BaseElement
*/
private static $icon = 'font-icon-block-file-list';

/**
* @var string
*/
private static $singular_name = 'File List Element';

/**
* @var string
*/
private static $plural_name = 'File List Elements';

/**
* @var string
*/
Expand All @@ -52,6 +42,19 @@ class ElementFileList extends BaseElement
*/
private static $inline_editable = false;

/**
* @param bool $includerelations
* @return array
*/
public function fieldLabels($includerelations = true)
{
$labels = parent::fieldLabels($includerelations);

$labels['Files'] = _t(__CLASS__.'.FilesLabel', 'Files');

return $labels;
}

/**
* @return FieldList
*/
Expand Down
20 changes: 19 additions & 1 deletion src/Model/FileListObject.php
Expand Up @@ -46,10 +46,25 @@ class FileListObject extends DataObject
* @var array
*/
private static $summary_fields = [
'File.Name' => 'File',
'File.Name',
'Title',
];

/**
* @param bool $includerelations
* @return array
*/
public function fieldLabels($includerelations = true)
{
$labels = parent::fieldLabels($includerelations);

$labels['Title'] = _t(__CLASS__.'.TitleLabel', 'Title');
$labels['File.Name'] = _t(__CLASS__.'.FileNameLabel', 'File');
$labels['File'] = _t(__CLASS__.'.FileLabel', 'File');

return $labels;
}

/**
* @var string
*/
Expand All @@ -62,6 +77,9 @@ public function getCMSFields()
{
$fields = parent::getCMSFields();

$fields->dataFieldByName('File')
->setTitle($this->fieldLabel('File'));

$fields->removeByName([
'FileListID',
'SortOrder',
Expand Down