First attempt at using l10n
Signed-off-by: Ryan Fletcher <ryan.fletcher@codepassion.ca>
This commit is contained in:
@@ -74,6 +74,8 @@ OC.L10N.register(
|
|||||||
"Shared boards" : "Shared boards",
|
"Shared boards" : "Shared boards",
|
||||||
"View more" : "View more",
|
"View more" : "View more",
|
||||||
"Move board to archive" : "Move board to archive",
|
"Move board to archive" : "Move board to archive",
|
||||||
"Create a new board" : "Create a new board"
|
"Create a new board" : "Create a new board",
|
||||||
|
"Personal": "Personal",
|
||||||
|
"To do": "To do"
|
||||||
},
|
},
|
||||||
"nplurals=2; plural=(n != 1);");
|
"nplurals=2; plural=(n != 1);");
|
||||||
|
|||||||
@@ -72,6 +72,8 @@
|
|||||||
"Shared boards" : "Shared boards",
|
"Shared boards" : "Shared boards",
|
||||||
"View more" : "View more",
|
"View more" : "View more",
|
||||||
"Move board to archive" : "Move board to archive",
|
"Move board to archive" : "Move board to archive",
|
||||||
"Create a new board" : "Create a new board"
|
"Create a new board" : "Create a new board",
|
||||||
|
"Personal": "Personal",
|
||||||
|
"To do": "To do"
|
||||||
},"pluralForm" :"nplurals=2; plural=(n != 1);"
|
},"pluralForm" :"nplurals=2; plural=(n != 1);"
|
||||||
}
|
}
|
||||||
@@ -27,22 +27,26 @@ use OCA\Deck\Service\DefaultBoardService;
|
|||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
|
use OCP\IL10N;
|
||||||
|
|
||||||
class PageController extends Controller {
|
class PageController extends Controller {
|
||||||
|
|
||||||
private $defaultBoardService;
|
private $defaultBoardService;
|
||||||
private $userId;
|
private $userId;
|
||||||
|
private $l10n;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$AppName,
|
$AppName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
DefaultBoardService $defaultBoardService,
|
DefaultBoardService $defaultBoardService,
|
||||||
|
IL10N $l10n,
|
||||||
$userId
|
$userId
|
||||||
) {
|
) {
|
||||||
parent::__construct($AppName, $request);
|
parent::__construct($AppName, $request);
|
||||||
|
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->defaultBoardService = $defaultBoardService;
|
$this->defaultBoardService = $defaultBoardService;
|
||||||
|
$this->l10n = $l10n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,9 +61,9 @@ class PageController extends Controller {
|
|||||||
'user' => $this->userId,
|
'user' => $this->userId,
|
||||||
'maxUploadSize' => \OCP\Util::uploadLimit(),
|
'maxUploadSize' => \OCP\Util::uploadLimit(),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($this->defaultBoardService->checkFirstRun($this->userId, $this->appName)) {
|
if ($this->defaultBoardService->checkFirstRun($this->userId, $this->appName)) {
|
||||||
$this->defaultBoardService->createDefaultBoard('Personal', $this->userId, '000000');
|
$this->defaultBoardService->createDefaultBoard($this->l10n->t('Personal'), $this->userId, '000000');
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TemplateResponse('deck', 'main', $params);
|
return new TemplateResponse('deck', 'main', $params);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ use OCA\Deck\Service\BoardService;
|
|||||||
use OCA\Deck\Service\StackService;
|
use OCA\Deck\Service\StackService;
|
||||||
use OCA\Deck\Service\CardService;
|
use OCA\Deck\Service\CardService;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
use OCP\IL10N;
|
||||||
|
|
||||||
class DefaultBoardService {
|
class DefaultBoardService {
|
||||||
|
|
||||||
@@ -36,8 +37,10 @@ class DefaultBoardService {
|
|||||||
private $stackService;
|
private $stackService;
|
||||||
private $cardService;
|
private $cardService;
|
||||||
private $config;
|
private $config;
|
||||||
|
private $l10n;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
IL10N $l10n,
|
||||||
BoardMapper $boardMapper,
|
BoardMapper $boardMapper,
|
||||||
BoardService $boardService,
|
BoardService $boardService,
|
||||||
StackService $stackService,
|
StackService $stackService,
|
||||||
@@ -50,6 +53,7 @@ class DefaultBoardService {
|
|||||||
$this->cardService = $cardService;
|
$this->cardService = $cardService;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->boardMapper = $boardMapper;
|
$this->boardMapper = $boardMapper;
|
||||||
|
$this->l10n = $l10n;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkFirstRun($userId, $appName) {
|
public function checkFirstRun($userId, $appName) {
|
||||||
@@ -69,16 +73,16 @@ class DefaultBoardService {
|
|||||||
$defaultStacks = [];
|
$defaultStacks = [];
|
||||||
$defaultCards = [];
|
$defaultCards = [];
|
||||||
|
|
||||||
$boardId = $defaultBoard->getId();
|
$boardId = $defaultBoard->getId();
|
||||||
|
|
||||||
$defaultStacks[] = $this->stackService->create('To do', $boardId, 1);
|
$defaultStacks[] = $this->stackService->create($this->l10n->t('To do'), $boardId, 1);
|
||||||
$defaultStacks[] = $this->stackService->create('Doing', $boardId, 1);
|
$defaultStacks[] = $this->stackService->create($this->l10n->t('Doing'), $boardId, 1);
|
||||||
$defaultStacks[] = $this->stackService->create('Done', $boardId, 1);
|
$defaultStacks[] = $this->stackService->create($this->l10n->t('Done'), $boardId, 1);
|
||||||
|
|
||||||
$defaultCards[] = $this->cardService->create('Example Task 3', $defaultStacks[0]->getId(), 'text', 0, $userId);
|
$defaultCards[] = $this->cardService->create($this->l10n->t('Example Task 3'), $defaultStacks[0]->getId(), 'text', 0, $userId);
|
||||||
$defaultCards[] = $this->cardService->create('Example Task 2', $defaultStacks[1]->getId(), 'text', 0, $userId);
|
$defaultCards[] = $this->cardService->create($this->l10n->t('Example Task 2'), $defaultStacks[1]->getId(), 'text', 0, $userId);
|
||||||
$defaultCards[] = $this->cardService->create('Example Task 1', $defaultStacks[2]->getId(), 'text', 0, $userId);
|
$defaultCards[] = $this->cardService->create($this->l10n->t('Example Task 1'), $defaultStacks[2]->getId(), 'text', 0, $userId);
|
||||||
|
|
||||||
return $defaultBoard;
|
return $defaultBoard;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,7 @@ use OCA\Deck\Service\BoardService;
|
|||||||
use OCA\Deck\Service\StackService;
|
use OCA\Deck\Service\StackService;
|
||||||
use OCA\Deck\Service\CardService;
|
use OCA\Deck\Service\CardService;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
use OCP\IL10N;
|
||||||
use \Test\TestCase;
|
use \Test\TestCase;
|
||||||
|
|
||||||
class DefaultBoardServiceTest extends TestCase {
|
class DefaultBoardServiceTest extends TestCase {
|
||||||
@@ -53,6 +54,8 @@ class DefaultBoardServiceTest extends TestCase {
|
|||||||
|
|
||||||
/** @var IConfig */
|
/** @var IConfig */
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
|
private $l10n;
|
||||||
|
|
||||||
private $userId = 'admin';
|
private $userId = 'admin';
|
||||||
|
|
||||||
@@ -63,8 +66,14 @@ class DefaultBoardServiceTest extends TestCase {
|
|||||||
$this->stackService = $this->createMock(StackService::class);
|
$this->stackService = $this->createMock(StackService::class);
|
||||||
$this->cardService = $this->createMock(CardService::class);
|
$this->cardService = $this->createMock(CardService::class);
|
||||||
$this->config = $this->createMock(IConfig::class);
|
$this->config = $this->createMock(IConfig::class);
|
||||||
|
|
||||||
|
$this->l10n = $this->request = $this->getMockBuilder(
|
||||||
|
'\OCP\IL10n')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
$this->service = new DefaultBoardService(
|
$this->service = new DefaultBoardService(
|
||||||
|
$this->l10n,
|
||||||
$this->boardMapper,
|
$this->boardMapper,
|
||||||
$this->boardService,
|
$this->boardService,
|
||||||
$this->stackService,
|
$this->stackService,
|
||||||
|
|||||||
Reference in New Issue
Block a user