Simple interface for western astrological signs.
The Western Signs library provides detailed information about each astrological sign, including its name
, element
, modality
, rulingPlanet
and glyph
, among other things. Additionally, you can specify the language for translations.
To install dependencies:
npm install western-signs
To use the getSignByName
function, import it along with the SIGNS
constant from the western-signs
package:
import { getSignByName, SIGNS } from 'western-signs'
Call the function with the desired astrological sign and optionally specify a language code. If no language code is provided, it defaults to English.
const data = getSignByName(SIGNS.TAURUS)
It should returns an object with the following properties:
{
bodyPart: 'Throat',
character: 'Bull',
element: 'Earth',
endDate: 2020-05-20T22:00:00.000Z,
glyph: '♉',
modality: 'Fixed',
name: 'Taurus',
number: 2,
pole: 'Negative',
rulingPlanet: 'Venus',
season: 'Spring',
startDate: 2020-04-20T22:00:00.000Z
}
The getSymbol
function allows you to retrieve SVG representations of astrological symbols, with options to customize their appearance.
import { getSymbol, SIGNS } from 'western-signs'
const symbol = getSymbol(SIGNS.TAURUS, {
stroke: 'brown',
strokeWidth: 2,
})
console.log(symbol.toString())
// Outputs: An SVG string with customized attributes
console.log(symbol.toDataURL())
// Outputs: A Data URL representation of the SVG
Use method chaining to modify the attributes of the symbol for a more fluent coding style.
const chainedSymbol = getSymbol('taurus')
.setStroke('orange')
.setStrokeWidth(3)
console.log(chainedSymbol.toString())
// Outputs: The SVG string with updated stroke attributes
You can easily translate aspects and other astrology-related terms using the t
function provided by the library. The t
function takes template strings and values to be translated based on the current language setting.
To translate an aspect into the current language:
import { ASPECTS, i18n } from 'western-signs'
const aspect = i18n.t`${ASPECTS.CONJUNCTION}`
console.log(aspect)
// Output: Conjunction
To change the language, use the setLanguage
function:
i18n.setLanguage('es')
const aspectInSpanish = i18n.t`${ASPECTS.CONJUNCTION}`
console.log(aspectInSpanish)
// Output: Conjunción
For more detailed API information, please check out the documentation.
MIT License © 2024 Marc Mariné