npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nabta-translations

v1.0.3

Published

Npm package for translations

Downloads

8

Readme

nabta-translations!

This is documentation for nabta-translations.

Author: Abdelrahman Moussa.

Installation Guide

npm install nabta-translations --save

Please note that you need to MANUALLY install ONLY IF NOT INSTALLED the following packages:

npm install @react-native-community/async-storage

npm install react-native-localization

npm install react-native-localize

npm install react-native-restart

Also note that some of this libraries may need manual linking so look at their documentation if any error occurred.

HOW TO USE

First import the package.

import { LocalizationContext } from 'nabta-translations'; import LocalizationProvider from 'nabta-translations';

Then use it like that :

  1. Firstly wrap the whole application with the LocalizationProvider and pass to it 2 props; json files containing the arabic and english translations. Here is an example :

          const en = require('./languages/en.json');
          const ar = require('./languages/ar.json');
    
          const App = () => {
            return (
              <SafeAreaView>
                <View>
                  <LocalizationProvider
                    ar = {{ ar }}
                    en = {{ en }}
                    languages = {{ languages }}
                  >
                      <TestingTranslations/>
                   </LocalizationProvider>
                </View>
              </SafeAreaView>
              )
          };
  2. Secondly in the child component of the app ( where you want to implement tranaslated text ) , you can access the text through the context like this :

     class TestingTranslations extends Component {
    
     constructor(props){
         super(props);
     }
    
     static contextType = LocalizationContext
    
     render(){
         this.context.initializeAppLanguage
         return(
             <Text>{this.context.translations["boiledEgg"]}</Text>
         )
     }
    }

Available Props

|Prop Name |Describtion |Type |Default Value | |----------------|--------------------------------|----------------|---------| |ar|Defines the JSON file containing all of the Arabic translations | JSON | NULL |en |Defines the JSON file containing all of the English translations |JSON | NULL

Available functions

AppLanguage , setAppLanguage and initializeApplanguage

should be accessed through the context, while

translateDigits

is a self contained exported function that can be accessed directly

|Object name |Description
|----------------|--------------------------------|----------------|---------| | appLanguage | returns the current language for the application
| setAppLanguage | Uset to set the language for the application by passing to it either en for English or ar for Arabic
| initializeAppLanguage | Used to initialize the language for the application and must be called at the root of the application. If the language of the application is predefined it restores it. Otherwise ( if the user opens the application for the first time ) , it checks the language of the mobile device itself and sets the language accordingly. For instance, if the phone language is set to Arabic then the application will initially be in Arabic until the user changes the language of the app.
| translateDigits | returns translated numbers