Skip to content

Commit

Permalink
Merge pull request #33 from crowdin/fix-directory-language-mapping
Browse files Browse the repository at this point in the history
directory replace (parent_id -> directory_id), added Language Mapping
  • Loading branch information
andrii-bodnar authored Dec 10, 2019
2 parents 99ab844 + 6541406 commit fa0985b
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/CrowdinApiClient/Api/DirectoryApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function get(int $projectId, int $directoryId): ?Directory
* @param array $data
* @internal string $data[name] required
* @internal integer $data[branchId]
* @internal integer $data[parentId]
* @internal integer $data[directoryId]
* @internal string $data[title]
* @internal string $data[exportPattern]
* @internal string $data[priority] Enum: "low" "normal" "high"
Expand Down
36 changes: 18 additions & 18 deletions src/CrowdinApiClient/Model/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Directory extends BaseModel
/**
* @var integer
*/
protected $parentId;
protected $directoryId;

/**
* @var string
Expand Down Expand Up @@ -65,7 +65,7 @@ public function __construct(array $data = [])
$this->id = (integer)$this->getDataProperty('id');
$this->projectId = (integer)$this->getDataProperty('projectId');
$this->branchId = (integer)$this->getDataProperty('branchId');
$this->parentId = (integer)$this->getDataProperty('parentId');
$this->directoryId = (integer)$this->getDataProperty('directoryId');
$this->name = (string)$this->getDataProperty('name');
$this->title = (string)$this->getDataProperty('title');
$this->exportPattern = (string)$this->getDataProperty('exportPattern');
Expand Down Expand Up @@ -106,22 +106,6 @@ public function setBranchId(int $branchId): void
$this->branchId = $branchId;
}

/**
* @return int
*/
public function getParentId(): int
{
return $this->parentId;
}

/**
* @param int $parentId
*/
public function setParentId(int $parentId): void
{
$this->parentId = $parentId;
}

/**
* @return string
*/
Expand Down Expand Up @@ -201,4 +185,20 @@ public function getUpdatedAt(): string
{
return $this->updatedAt;
}

/**
* @return int
*/
public function getDirectoryId(): int
{
return $this->directoryId;
}

/**
* @param int $directoryId
*/
public function setDirectoryId(int $directoryId): void
{
$this->directoryId = $directoryId;
}
}
22 changes: 22 additions & 0 deletions src/CrowdinApiClient/Model/ProjectSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ class ProjectSetting extends BaseModel
*/
protected $qaCheckCategories = [];

/**
* @var array
*/
protected $languageMapping = [];

public function __construct(array $data = [])
{
parent::__construct($data);
Expand All @@ -96,6 +101,7 @@ public function __construct(array $data = [])
$this->qaCheckIsActive = (bool)$this->getDataProperty('qaCheckIsActive');
$this->lowestQualityProjectGoalId = (integer)$this->getDataProperty('lowestQualityProjectGoalId');
$this->qaCheckCategories = (array)$this->getDataProperty('qaCheckCategories');
$this->languageMapping = (array)$this->getDataProperty('languageMapping');
}

/**
Expand Down Expand Up @@ -313,4 +319,20 @@ public function setJiptPseudoLanguageId(string $jiptPseudoLanguageId): void
{
$this->jiptPseudoLanguageId = $jiptPseudoLanguageId;
}

/**
* @return array
*/
public function getLanguageMapping(): array
{
return $this->languageMapping;
}

/**
* @param array $languageMapping
*/
public function setLanguageMapping(array $languageMapping): void
{
$this->languageMapping = $languageMapping;
}
}
2 changes: 1 addition & 1 deletion tests/CrowdinApiClient/Api/DirectoryApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function testList()
"id": 4,
"projectId": 2,
"branchId": 34,
"parentId": 0,
"directoryId": 0,
"name": "main",
"title": "<Description materials>",
"exportPattern": "/localization/%locale%/%file_name%",
Expand Down
24 changes: 24 additions & 0 deletions tests/CrowdinApiClient/Api/ProjectApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ public function testGetAndUpdateSettings()
"wrongTranslation": true,
"spellcheck": true,
"icu": true
},
"languageMapping": {
"uk": {
"name": "Ukranian",
"two_letters_code": "ua",
"three_letters_code": "ukr",
"locale": "uk-UA",
"locale_with_underscore": "uk_UA",
"android_code": "uk-rUA",
"osx_code": "ua.lproj",
"osx_locale": "ua"
}
}
}
}');
Expand Down Expand Up @@ -249,6 +261,18 @@ public function testGetAndUpdateSettings()
"wrongTranslation": true,
"spellcheck": true,
"icu": true
},
"languageMapping": {
"uk": {
"name": "Ukranian",
"two_letters_code": "ua",
"three_letters_code": "ukr",
"locale": "uk-UA",
"locale_with_underscore": "uk_UA",
"android_code": "uk-rUA",
"osx_code": "ua.lproj",
"osx_locale": "ua"
}
}
}
}');
Expand Down
8 changes: 4 additions & 4 deletions tests/CrowdinApiClient/Model/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DirectoryTest extends TestCase
'id' => 4,
'projectId' => 2,
'branchId' => 34,
'parentId' => 0,
'directoryId' => 0,
'name' => 'main',
'title' => '<Description materials>',
'exportPattern' => '/localization/%locale%/%file_name%',
Expand All @@ -42,14 +42,14 @@ public function testSetData()
{
$this->directory = new Directory();
$this->directory->setBranchId($this->data['branchId']);
$this->directory->setParentId($this->data['parentId']);
$this->directory->setDirectoryId($this->data['directoryId']);
$this->directory->setName($this->data['name']);
$this->directory->setTitle($this->data['title']);
$this->directory->setExportPattern($this->data['exportPattern']);
$this->directory->setPriority($this->data['priority']);

$this->assertEquals($this->data['branchId'], $this->directory->getBranchId());
$this->assertEquals($this->data['parentId'], $this->directory->getParentId());
$this->assertEquals($this->data['directoryId'], $this->directory->getDirectoryId());
$this->assertEquals($this->data['name'], $this->directory->getName());
$this->assertEquals($this->data['title'], $this->directory->getTitle());
$this->assertEquals($this->data['exportPattern'], $this->directory->getExportPattern());
Expand All @@ -61,7 +61,7 @@ public function checkData()
$this->assertEquals($this->data['id'], $this->directory->getId());
$this->assertEquals($this->data['projectId'], $this->directory->getProjectId());
$this->assertEquals($this->data['branchId'], $this->directory->getBranchId());
$this->assertEquals($this->data['parentId'], $this->directory->getParentId());
$this->assertEquals($this->data['directoryId'], $this->directory->getDirectoryId());
$this->assertEquals($this->data['name'], $this->directory->getName());
$this->assertEquals($this->data['title'], $this->directory->getTitle());
$this->assertEquals($this->data['exportPattern'], $this->directory->getExportPattern());
Expand Down
17 changes: 17 additions & 0 deletions tests/CrowdinApiClient/Model/ProjectSettingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ class ProjectSettingTest extends TestCase
'spellcheck' => true,
'icu' => true,
],
'languageMapping' =>
[
'uk' =>
[
'name' => 'Ukranian',
'two_letters_code' => 'ua',
'three_letters_code' => 'ukr',
'locale' => 'uk-UA',
'locale_with_underscore' => 'uk_UA',
'android_code' => 'uk-rUA',
'osx_code' => 'ua.lproj',
'osx_locale' => 'ua',
],
],
];

/**
Expand Down Expand Up @@ -77,6 +91,7 @@ public function testSetData()
$this->projectSetting->setQaCheckIsActive($this->data['qaCheckIsActive']);
$this->projectSetting->setLowestQualityProjectGoalId($this->data['lowestQualityProjectGoalId']);
$this->projectSetting->setQaCheckCategories($this->data['qaCheckCategories']);
$this->projectSetting->setLanguageMapping($this->data['languageMapping']);

$this->assertEquals($this->data['translateDuplicates'], $this->projectSetting->getTranslateDuplicates());
$this->assertEquals($this->data['isMtAllowed'], $this->projectSetting->isMtAllowed());
Expand All @@ -91,6 +106,7 @@ public function testSetData()
$this->assertEquals($this->data['qaCheckIsActive'], $this->projectSetting->isQaCheckIsActive());
$this->assertEquals($this->data['lowestQualityProjectGoalId'], $this->projectSetting->getLowestQualityProjectGoalId());
$this->assertEquals($this->data['qaCheckCategories'], $this->projectSetting->getQaCheckCategories());
$this->assertEquals($this->data['languageMapping'], $this->projectSetting->getLanguageMapping());
}

public function checkData()
Expand All @@ -109,5 +125,6 @@ public function checkData()
$this->assertEquals($this->data['qaCheckIsActive'], $this->projectSetting->isQaCheckIsActive());
$this->assertEquals($this->data['lowestQualityProjectGoalId'], $this->projectSetting->getLowestQualityProjectGoalId());
$this->assertEquals($this->data['qaCheckCategories'], $this->projectSetting->getQaCheckCategories());
$this->assertEquals($this->data['languageMapping'], $this->projectSetting->getLanguageMapping());
}
}

0 comments on commit fa0985b

Please sign in to comment.