Skip to content

Commit

Permalink
Merge pull request #72 from ba-st/localization
Browse files Browse the repository at this point in the history
Move LanguageTag and LanguageRange to Buoy
  • Loading branch information
gcotelli authored Jul 19, 2024
2 parents 266b05c + cc59ad1 commit 4a1065f
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 605 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ To learn about the project, [install it](how-to/how-to-load-in-pharo.md) and
take a look at the reference documentation:

- **Errors** [Exceptions modelling HTTP errors](reference/Errors.md)
- **IETF related abstractions**: [ETags, web links, language tags and ranges](reference/IETF.md)
- **IETF related abstractions**: [ETags and web links](reference/IETF.md)
- **Resilience operators**: [Building blocks for resilient applications](reference/Resilience.md)
- **Zinc extensions**: Useful [extensions](reference/Zinc.md) to Zinc objects

Expand Down
62 changes: 0 additions & 62 deletions docs/reference/IETF.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,68 +79,6 @@ are provided as configuration methods:
`ZnResponse` instances allow adding one or more links via `addLink:` receiving
a `WebLink` instance or access the link collection by sending `links`.

## Language Tags and Ranges

Language Tags are represented by instances of `LanguageTag`. A language tag is
used to label the language used by some information content.

These tags can also be used to specify the user's preferences when selecting
information content or to label additional attributes of content and associated
resources.

Sometimes language tags are used to indicate additional language attributes of
the content.

Language tags can be created by providing a subtags list or by parsing its
string representation:

```smalltalk
LanguageTag from: #('en' 'Latn' 'US').
LanguageTag fromString: 'en-us'.
'en-us' asLanguageTag.
```

Its instances can respond the language code (`languageCode`) and provide
methods to access its script and region in case they are defined:

```smalltalk
tag withScriptDo: [:script | ].
tag withRegionDo: [:region| ].
```

This implementation does not do anything special with the other optional
subtags that can be defined; nor supports extended languages and regions in UN
M.49 codes.

Language ranges are represented by instances of `LanguageRange`. A language
range has the same syntax as a language-tag, or is the single character `"*"`.

A language range matches a language tag if it exactly equals the tag, or if it
exactly equals a prefix of the tag such that the first character following the
prefix is `"-"`.

The special range `"*"` matches any tag. A protocol that uses
language ranges may specify additional rules about the semantics of
`"*"`; for instance, `HTTP/1.1` specifies that the range `"*"` matches only
languages not matched by any other range within an `"Accept-Language:"` header.

Language ranges can be created by sending the message `any`, providing a list
of subtags, or parsing its string representation:

```smalltalk
LanguageRange any.
LanguageRange from: #('en').
LanguageRange fromString: '*'.
LanguageRange fromString: 'es-AR'.
```

`LanguageRange` instances are capable of matching corresponding language tags.
For example:

```smalltalk
(LanguageRange fromString: 'es') matches: 'es-AR' asLanguageTag "==> true"
```

**References:**

- [RFC 5646](https://www.rfc-editor.org/rfc/rfc5646.html)
Expand Down
2 changes: 1 addition & 1 deletion rowan/components/Dependent-SUnit-Extensions.ston
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
RwSimpleProjectLoadComponentV2 {
#name : 'Dependent-SUnit-Extensions',
#condition : 'sunit',
#projectNames : [ ],
#projectNames : [ ],
#componentNames : [
'Deployment'
],
Expand Down
2 changes: 2 additions & 0 deletions rowan/components/Deployment.ston
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ RwSimpleProjectLoadComponentV2 {
],
#componentNames : [ ],
#packageNames : [
'Hyperspace-Buoy-Extensions',
'Hyperspace-Model',
'Hyperspace-Extensions',
'Hyperspace-GS64-Extensions'
Expand All @@ -14,6 +15,7 @@ RwSimpleProjectLoadComponentV2 {
'gemstone' : {
'allusers' : {
#packageNameToPlatformPropertiesMap : {
'Hyperspace-Buoy-Extensions' : { 'symbolDictName' : 'Buoy' },
'Hyperspace-Model' : { 'symbolDictName' : 'Hyperspace' },
'Hyperspace-Extensions' : { 'symbolDictName' : 'Zinc' },
'Hyperspace-GS64-Extensions' : { 'symbolDictName' : 'Globals' }
Expand Down
2 changes: 1 addition & 1 deletion rowan/projects/Bell.ston
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ RwLoadSpecificationV2 {
#specName: 'Bell',
#projectName : 'Bell',
#gitUrl : 'https://github.com/ba-st/Bell.git',
#revision : 'v2',
#revision : 'v3',
#projectSpecFile : 'rowan/project.ston',
#componentNames : [
'Deployment',
Expand Down
2 changes: 1 addition & 1 deletion rowan/projects/Zinc.ston
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ RwLoadSpecificationV2 {
#specName: 'Zinc',
#projectName : 'Zinc',
#gitUrl : 'https://github.com/ba-st-dependencies/Zinc.git',
#revision : 'v5',
#revision : 'v6',
#projectSpecFile : 'rowan/project.ston',
#componentNames : [
'Deployment'
Expand Down
50 changes: 24 additions & 26 deletions source/BaselineOfHyperspace/BaselineOfHyperspace.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ BaselineOfHyperspace >> projectClass [
BaselineOfHyperspace >> setUpDependencies: spec [

spec
baseline: 'Buoy' with: [ spec repository: 'github://ba-st/Buoy:v7' ];
baseline: 'Buoy' with: [ spec repository: 'github://ba-st/Buoy:v8' ];
project: 'Buoy-Deployment' copyFrom: 'Buoy' with: [ spec loads: 'Deployment' ];
project: 'Buoy-SUnit' copyFrom: 'Buoy' with: [ spec loads: 'Dependent-SUnit-Extensions' ];
project: 'Buoy-Tools' copyFrom: 'Buoy' with: [ spec loads: 'Tools' ].
Expand All @@ -47,40 +47,38 @@ BaselineOfHyperspace >> setUpDependencies: spec [
project: 'Zinc-Core' copyFrom: 'ZincHTTPComponents' with: [ spec loads: 'Core' ].

spec
baseline: 'Bell' with: [ spec repository: 'github://ba-st/Bell:v2' ];
baseline: 'Bell' with: [ spec repository: 'github://ba-st/Bell:v3' ];
project: 'Bell-Deployment' copyFrom: 'Bell' with: [ spec loads: 'Deployment' ];
project: 'Bell-SUnit' copyFrom: 'Bell' with: [ spec loads: 'Dependent-SUnit-Extensions' ]
]

{ #category : 'initialization' }
BaselineOfHyperspace >> setUpPackages: spec [

spec
package: 'Hyperspace-Model' with: [ spec requires: #('Buoy-Deployment' 'Zinc-Core' 'Bell-Deployment')];
group: 'Deployment' with: 'Hyperspace-Model';
package: 'Hyperspace-Extensions'
with: [ spec requires: 'Hyperspace-Model' ];
group: 'Deployment' with: 'Hyperspace-Extensions';
package: 'Hyperspace-Pharo-Extensions'
with: [ spec requires: 'Hyperspace-Model' ];
group: 'Deployment' with: 'Hyperspace-Pharo-Extensions'.
spec
package: 'Hyperspace-Model' with: [ spec requires: #( 'Buoy-Deployment' 'Zinc-Core' 'Bell-Deployment') ];
group: 'Deployment' with: 'Hyperspace-Model';
package: 'Hyperspace-Extensions' with: [ spec requires: 'Hyperspace-Model' ];
group: 'Deployment' with: 'Hyperspace-Extensions';
package: 'Hyperspace-Buoy-Extensions' with: [ spec requires: 'Hyperspace-Model' ];
group: 'Deployment' with: 'Hyperspace-Buoy-Extensions';
package: 'Hyperspace-Pharo-Extensions' with: [ spec requires: 'Hyperspace-Model' ];
group: 'Deployment' with: 'Hyperspace-Pharo-Extensions'.

spec
package: 'Hyperspace-Model-Tests' with: [
spec requires:
#( 'Hyperspace-Model' 'Hyperspace-Extensions'
'Hyperspace-Pharo-Extensions' 'Dependent-SUnit-Extensions' 'Bell-SUnit') ];
group: 'Tests' with: 'Hyperspace-Model-Tests'.
spec
package: 'Hyperspace-Model-Tests' with: [
spec requires: #( 'Hyperspace-Model' 'Hyperspace-Extensions' 'Hyperspace-Pharo-Extensions'
'Hyperspace-Buoy-Extensions' 'Dependent-SUnit-Extensions' 'Bell-SUnit')
];
group: 'Tests' with: 'Hyperspace-Model-Tests'.

spec
package: 'Hyperspace-SUnit-Model'
with: [ spec requires: 'Buoy-SUnit' ];
group: 'Dependent-SUnit-Extensions' with: 'Hyperspace-SUnit-Model';
package: 'Hyperspace-SUnit-Model-Tests'
with: [ spec requires: 'Hyperspace-SUnit-Model' ];
group: 'Tests' with: 'Hyperspace-SUnit-Model-Tests'.

spec group: 'Tools' with: 'Buoy-Tools'
spec
package: 'Hyperspace-SUnit-Model' with: [ spec requires: 'Buoy-SUnit' ];
group: 'Dependent-SUnit-Extensions' with: 'Hyperspace-SUnit-Model';
package: 'Hyperspace-SUnit-Model-Tests' with: [ spec requires: 'Hyperspace-SUnit-Model' ];
group: 'Tests' with: 'Hyperspace-SUnit-Model-Tests'.

spec group: 'Tools' with: 'Buoy-Tools'
]

{ #category : 'initialization' }
Expand Down
7 changes: 7 additions & 0 deletions source/Hyperspace-Buoy-Extensions/LanguageTag.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : 'LanguageTag' }

{ #category : '*Hyperspace-Buoy-Extensions' }
LanguageTag >> asByteArray [

^ self printString asByteArray
]
1 change: 1 addition & 0 deletions source/Hyperspace-Buoy-Extensions/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : 'Hyperspace-Buoy-Extensions' }
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ CharacterCollection >> asEntityTag [
^ EntityTag fromString: self
]

{ #category : #'*Hyperspace-GS64-Extensions' }
CharacterCollection >> asLanguageTag [

^ LanguageTag fromString: self
]

{ #category : #'*Hyperspace-GS64-Extensions' }
CharacterCollection >> asMediaType [

Expand Down
76 changes: 0 additions & 76 deletions source/Hyperspace-Model-Tests/LanguageRangeTest.class.st

This file was deleted.

Loading

0 comments on commit 4a1065f

Please sign in to comment.