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

Added PATCH option to Rest API #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Controller/RestApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,21 @@ public function project($name, $lang = null) {

return $obj;
}

public function updateProject($name) {
$values = $this->param('values');
$project = $this->app->storage->findOne('lokalize/projects', [
'name' => $name
]);

if (!$values || !$name || !$project) {
return false;
}

$_project = $this->module('lokalize')->project($project['_id']);
$_project['values'] = array_replace_recursive($_project["values"], $values);
$_project['_modified'] = time();

return $this->module('lokalize')->saveProject($_project);
}
}
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,25 @@ lokalize:
Get localized strings of a project:

```
/api/lokalize/project/{name}?token=*apitoken*
GET /api/lokalize/project/{name}?token=*apitoken*
```

Get strings for a specific language

```
/api/lokalize/project/{name}/{local}?token=*apitoken*
GET /api/lokalize/project/{name}/{local}?token=*apitoken*
```

Update localized strings of a project:

```
PATCH /api/lokalize/project/{name}?token=*apitoken*
```

Update strings for a specific language

```
PATCH /api/lokalize/project/{name}/{local}?token=*apitoken*
```

### 💐 SPONSORED BY
Expand Down