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

feat: add norwegian pronouns (incomplete) #109

Draft
wants to merge 1 commit into
base: mistress
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions packages/pronouns/src/sets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
*/

import * as enSets from './sets/en.js'
import * as nbSets from './sets/nb.js'
import * as nnSets from './sets/nn.js'

export type Sets = [ string ] | [ string, string ] | [ string, string, string ]

Expand Down Expand Up @@ -61,4 +63,6 @@ export type SetDefinition = {

export const PronounSets: Record<string, SetDefinition> = {
en: enSets,
nb: nbSets,
nn: nnSets,
}
151 changes: 151 additions & 0 deletions packages/pronouns/src/sets/nb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/*
* Copyright (c) Cynthia Rey et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import type { Sets } from '../sets.js'
import { formatPronounSetShort } from '../formatter.js'

//!\\ CONTRIBUTORS, KEEP PRONOUNS SORTED PER CATEGORY AND ALPHABETICALLY //!\\

export const sets = <const> {
// Nominative
de: {
classic: {
standard: [ 'de', 'dem' ],
capitalized: [ 'De', 'Dem' ],
},
},
det: {
classic: {
standard: [ 'det', 'det' ],
capitalized: [ 'Det', 'Det' ],
},
},
han: {
classic: {
standard: [ 'han', 'ham' ],
capitalized: [ 'Han', 'Ham' ],
},
},
hen: {
classic: {
standard: [ 'hen', 'hen' ],
capitalized: [ 'Hen', 'Hen' ],
},
},
hun: {
classic: {
standard: [ 'hun', 'henne' ],
capitalized: [ 'Hun', 'Henne' ],
},
},

// Meta
alle: {
classic: {
standard: 'Alle pronomen',
},
short: {
standard: 'alle',
capitalized: 'Alle',
},
},
andre: {
classic: {
standard: 'Andre pronomen',
},
short: {
standard: 'andre',
capitalized: 'Andre',
},
},
spør: {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite unsure about non-ascii identifiers here

classic: {
standard: 'Spør meg om pronomena mine',
},
short: {
standard: 'spør',
capitalized: 'Spør',
},
},
unngå: {
classic: {
standard: 'Unngå pronomen, bruk navnet mitt',
},
short: {
standard: 'unngå',
capitalized: 'Unngå',
},
},
}

export const categories = {
nominative: [ 'de', 'det', 'han', 'hen', 'hun' ],
meta: [ 'alle', 'spør', 'unngå', 'andre' ],
}

export const properties = {
unique: ['unngå'],
final: ['alle', 'spør', 'unngå', 'andre'],
}

export function formatLong (s: Sets) {
if (s[0] === 'spør') {
return 'Foretrekker å bli spurt om pronomena sine'
}

if (s[0] === 'unngå') {
return 'Vil unngå pronomen'
}

if (s[0] === 'andre') {
return 'Bruker pronomen som ikke er tilgjengelige på PronounDB'
}

let res = 'Bruker '
for (let i = 0; i < s.length; i++) {
const set = s[i]
if (set === 'spør') {
return `${res} pronomen. Du kan også spørre denne personen om mer informasjon`
}

if (set === 'andre') {
return `${res} pronomen. Denne personen bruker også pronomen som ikke er tilgjengelige på PronounDB`
}

const pronouns = formatPronounSetShort(set, false, 'nn')

if (i) {
res += ', '
if (i === s.length - 1) res += 'eller '
}

res += set === 'alle' ? pronouns : `"${pronouns}"`
}

return `${res} pronomen`
}
151 changes: 151 additions & 0 deletions packages/pronouns/src/sets/nn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/*
* Copyright (c) Cynthia Rey et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import type { Sets } from '../sets.js'
import { formatPronounSetShort } from '../formatter.js'

//!\\ CONTRIBUTORS, KEEP PRONOUNS SORTED PER CATEGORY AND ALPHABETICALLY //!\\

export const sets = <const> {
// Nominative
dei: {
classic: {
standard: [ 'dei', 'dei' ],
capitalized: [ 'Dei', 'Dei' ],
},
},
det: {
classic: {
standard: [ 'det', 'det' ],
capitalized: [ 'Det', 'Det' ],
},
},
han: {
classic: {
standard: [ 'han', 'han' ],
capitalized: [ 'Han', 'Han' ],
},
},
hen: {
classic: {
standard: [ 'hen', 'hen' ],
capitalized: [ 'Hen', 'Hen' ],
},
},
ho: {
classic: {
standard: [ 'ho', 'henne' ],
capitalized: [ 'Ho', 'Henne' ],
},
},

// Meta
alle: {
classic: {
standard: 'Alle pronomen',
},
short: {
standard: 'alle',
capitalized: 'Alle',
},
},
andre: {
classic: {
standard: 'Andre pronomen',
},
short: {
standard: 'andre',
capitalized: 'Andre',
},
},
spør: {
classic: {
standard: 'Spør meg om pronomena mine',
},
short: {
standard: 'spør',
capitalized: 'Spør',
},
},
unngå: {
classic: {
standard: 'Unngå pronomen, bruk namnet mitt',
},
short: {
standard: 'unngå',
capitalized: 'Unngå',
},
},
}

export const categories = {
nominative: [ 'dei', 'det', 'han', 'hen', 'ho' ],
meta: [ 'alle', 'andre', 'spør', 'unngå' ],
}

export const properties = {
unique: ['unngå'],
final: ['alle', 'andre', 'spør', 'unngå'],
}

export function formatLong (s: Sets) {
if (s[0] === 'spør') {
return 'Føretrekkjer å bli spurt om pronomena sine'
}

if (s[0] === 'unngå') {
return 'Vil unngå pronomen'
}

if (s[0] === 'andre') {
return 'Bruker pronomen som ikkje er tilgjengelege på PronounDB'
}

let res = 'Bruker '
for (let i = 0; i < s.length; i++) {
const set = s[i]
if (set === 'spør') {
return `${res} pronomen. Du kan òg spørja denne personen om meir informasjon`
}

if (set === 'andre') {
return `${res} pronomen. Denne personen bruker òg pronomen som ikkje er tilgjengelege på PronounDB`
}

const pronouns = formatPronounSetShort(set, false, 'nn')

if (i) {
res += ', '
if (i === s.length - 1) res += 'eller '
}

res += set === 'alle' ? pronouns : `"${pronouns}"`
}

return `${res} pronomen`
}
2 changes: 1 addition & 1 deletion packages/website/src/pages/wiki/api-docs.astro
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const flash = handleFlash(Astro)
<p class='mb-2'>Each locale has a list of pronouns set available to it.</p>
<div class='flex flex-none gap-4 items-center mb-4 px-4 py-2 font-semibold border rounded text-blue-600 border-blue-600 dark:text-blue-400 dark:border-blue-400'>
<div class='w-6 h-6 shrink-0' set:html={infoIcon}/>
<p>Only the "en" locale is supported at this time.</p>
<p>Only the "en", "nb", and "nn" locales are supported at this time.</p>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would probably best be replaced by some other message, as this was intended to outline the fact while the structure seems to indicate there may be multiple languages, only en is implemented.

The documentation should explain the canonical behavior for dealing with sets in multiple languages, what to pick etc. which is currently undefined as I haven't got around experimenting with it

</div>
<ul class='list-disc list-inside mb-4'>
{Object.keys(PronounSets).map((locale) => (
Expand Down