Skip to content

Commit

Permalink
align the namespace with other Liturgical Calendar projects
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRDOrazio committed Nov 5, 2024
1 parent 43ab740 commit bc5c07e
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 37 deletions.
53 changes: 45 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,58 @@ The API takes the following parameters:
* **`YEAR`**: the year for which anniversaries will be calculated. For example, if Saint Ignatius was canonized in 1622, and the value `2022` is supplied to the **`YEAR`** parameter, then a `CENTENARY` anniversary of 400 years will be returned.
* **`LOCALE`**: the language in which strings should be translated / localized.

# Development
## Installation

To test the API locally, simply launch using PHP's built-in server: `php -S localhost:8000`. You can choose to serve over a different port if you wish.
### Composer *(recommended)*

# Locales

In order to obtain localized results in development, you must have the correct locales installed on your local machine.
In your project directory issue `composer require liturgical-calendar/anniversarycalculator`. The package will be installed to the `vendor` folder and the requirement added to your `composer.json`.

Run `locale -a` and check to see if <kbd>de_DE.utf8</kbd>, <kbd>es_ES.utf8</kbd>, <kbd>fr_FR.utf8</kbd>, <kbd>it_IT.utf8</kbd>, <kbd>nl_NL.utf8</kbd>, <kbd>pt_PT.utf8</kbd> are among the results.
### Git

For any locales that are not installed, you will not get translation results for certain strings.
You can also clone the repository to your project folder (useful mostly for development of the API and contributing to the codebase):

In order to install a locale on Ubuntu, run `sudo apt-get install language-pack-{two-letter-iso-code}`. For example `sudo apt-get install language-pack-es` will install the Spanish locale on your machine. You will then be able to get translation results for Spanish.
```console
git clone https://github.com/Liturgical-Calendar/LitCalAnniversaryCalculator.git .
composer install
```

# Translation into other languages
This will clone the repository into the current folder rather than to a folder with the same name as the repository, and then install the package for inclusion in your scripts.

A sample `index.php` script is included.

## Usage

If you installed the package via git, you should already have a sample `index.php` file.

If you installed the package via composer, create a script similar to the following:

```php
// index.php
<?php

use LiturgicalCalendar\AnniversaryCalculator;

require_once 'vendor/autoload.php';

$calculator = new AnniversaryCalculator();
$calculator->init();
```

Then to test the API locally simply launch using PHP's built-in server: `php -S localhost:8000`. You can choose to serve over a different port if you wish.

Now open **localhost:8000** in your browser. You should see a JSON response. You can change the year and the locale using the `YEAR` and `LOCALE` query parameters.

> [!NOTE]
> In order to obtain localized results, you must have the correct locales installed.
>
> Run `locale -a` and check to see if <kbd>de_DE.utf8</kbd>, <kbd>es_ES.utf8</kbd>, <kbd>fr_FR.utf8</kbd>, <kbd>it_IT.utf8</kbd>, <kbd>nl_NL.utf8</kbd>, <kbd>pt_PT.utf8</kbd> are among the results.
>
> For any locales that are not installed, you will not get translation results for certain strings.
>
> In order to install a locale on Ubuntu, run `sudo apt-get install language-pack-{two-letter-iso-code}`. For example `sudo apt-get install language-pack-es` will install the Spanish locale on your machine. You will then be able to get translation results for Spanish.
## Translation into other languages

<a href="https://translate.johnromanodorazio.com/engage/liturgical-calendar/">
<img src="https://translate.johnromanodorazio.com/widgets/liturgical-calendar/-/liturgical-anniversary-calculator-data/open-graph.png" alt="Translation status" />
Expand Down
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"name": "litcal/anniversarycalculator",
"name": "liturgical-calendar/anniversarycalculator",
"description": "an API that calculates anniversaries of liturgical recurrences from the General Roman Calendar",
"type": "library",
"require-dev": {
"squizlabs/php_codesniffer": "^3.10"
},
"require": {
"php": ">=7.4"
},
"license": "MIT",
"autoload": {
"psr-4": {
"LitCal\\": "src/"
"LiturgicalCalendar\\": "src/"
},
"files": ["src/pgettext.php"]
},
Expand All @@ -19,5 +22,6 @@
}
],
"minimum-stability": "stable",
"require": {}
"config": {
}
}
20 changes: 11 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?php

use LitCal\AnniversaryCalculator;
use LiturgicalCalendar\AnniversaryCalculator;

// error_reporting(E_ALL);
// ini_set('display_errors', 1);
ini_set('date.timezone', 'Europe/Vatican');
require_once 'vendor/autoload.php';

$calculator = new AnniversaryCalculator();
Expand Down
6 changes: 3 additions & 3 deletions src/AnniversaryCalculator.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace LitCal;
namespace LiturgicalCalendar;

use LitCal\AnniversaryCalculator\AnniversaryEvent;
use LitCal\AnniversaryCalculator\Enums\StatusCode;
use LiturgicalCalendar\AnniversaryCalculator\AnniversaryEvent;
use LiturgicalCalendar\AnniversaryCalculator\Enums\StatusCode;

class AnniversaryCalculator
{
Expand Down
8 changes: 4 additions & 4 deletions src/AnniversaryCalculator/AnniversaryEvent.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace LitCal\AnniversaryCalculator;
namespace LiturgicalCalendar\AnniversaryCalculator;

use LitCal\AnniversaryCalculator\Enums\AnnivType;
use LitCal\AnniversaryCalculator\Enums\AreaInterest;
use LitCal\AnniversaryCalculator\Enums\LitCalendar;
use LiturgicalCalendar\AnniversaryCalculator\Enums\AnnivType;
use LiturgicalCalendar\AnniversaryCalculator\Enums\AreaInterest;
use LiturgicalCalendar\AnniversaryCalculator\Enums\LitCalendar;

class AnniversaryEvent
{
Expand Down
2 changes: 1 addition & 1 deletion src/AnniversaryCalculator/Enums/AnnivType.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace LitCal\AnniversaryCalculator\Enums;
namespace LiturgicalCalendar\AnniversaryCalculator\Enums;

class AnnivType
{
Expand Down
2 changes: 1 addition & 1 deletion src/AnniversaryCalculator/Enums/AreaInterest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace LitCal\AnniversaryCalculator\Enums;
namespace LiturgicalCalendar\AnniversaryCalculator\Enums;

class AreaInterest
{
Expand Down
6 changes: 3 additions & 3 deletions src/AnniversaryCalculator/Enums/LitCalendar.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace LitCal\AnniversaryCalculator\Enums;
namespace LiturgicalCalendar\AnniversaryCalculator\Enums;

class LitCalendar
{
public const UNIVERSAL = "universal";
public const NATIONAL = "national";
public const DIOCESAN = "diocesan";
public const NATIONAL = "national";
public const DIOCESAN = "diocesan";
public const WIDE_AREA = "wide_area";
private array $GTXT;

Expand Down
2 changes: 1 addition & 1 deletion src/AnniversaryCalculator/Enums/StatusCode.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace LitCal\AnniversaryCalculator\Enums;
namespace LiturgicalCalendar\AnniversaryCalculator\Enums;

class StatusCode
{
Expand Down

0 comments on commit bc5c07e

Please sign in to comment.