# Package problem

**URL:** <https://forums.fusetools.com/t/package-problem/6089>\
**Category:** How-to Discussions\
**Created:** [March 13, 2018, 8:04am UTC](https://forums.fusetools.com/t/package-problem/6089 "2018-03-13T08:04:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Predrag\_Dislenkovic](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@Predrag\_Dislenkovic](https://forums.fusetools.com/u/Predrag_Dislenkovic)\
**Post date:** [March 13, 2018, 8:04am UTC](https://forums.fusetools.com/t/package-problem/6089/1 "2018-03-13T08:04:32Z")

</div>

While android previewing the app , this error shows up:  
C:\Users\USER\Documents\GitHub\MyIQFinanceMobile\DeviceLocale.uno(30,24): Error E3107: ‘Language’ does not contain a member called ‘Java’. Could you be missing a package reference

And this is DeviceLocale.uno code:

using Uno;  
using Uno.UX;  
using Uno.Text;  
using Uno.Collections;  
using Uno.Compiler.ExportTargetInterop;  
using Fuse;  
using Fuse.Scripting;  
using Fuse.Reactive;  
[extern(Android)ForeignInclude(Language.Java, “android.app.Activity”, “android.provider.Settings”,  
“android.content._","java.security._”, “java.util.regex._", "java.util._”,  
“[java.net](http://java.net)._", "java.nio._”, “[java.io](http://java.io).\*”)]

[extern(iOS) ForeignInclude(Language.ObjC, “sys/types.h”, “sys/sysctl.h”)]

[UXGlobalModule]  
public sealed class DeviceLocale : NativeModule {  
static readonly DeviceLocale \_instance;

```
public DeviceLocale() : base() {
    if (_instance != null) return;
    Uno.UX.Resource.SetGlobalKey(_instance = this, "DeviceLocale");

    AddMember(new NativeProperty< string, object >("locale", GetCurrentLocale));
}

[Foreign(Language.Java)]
public static extern(Android) string GetCurrentLocale()
@{
	Locale loc = java.util.Locale.getDefault();

    final char separator = '-';
    String language = loc.getLanguage();
    String region = loc.getCountry();
    String variant = loc.getVariant();

    // special case for Norwegian Nynorsk since "NY" cannot be a variant as per BCP 47
    // this goes before the string matching since "NY" wont pass the variant checks
    if (language.equals("no") && region.equals("NO") && variant.equals("NY")) {
        language = "nn";
        region = "NO";
        variant = "";
    }

    if (language.isEmpty() || !language.matches("\\p{Alpha}{2,8}")) {
        language = "und"; // "und" for Undetermined
    } else if (language.equals("iw")) {
        language = "he"; // correct deprecated "Hebrew"
    } else if (language.equals("in")) {
        language = "id"; // correct deprecated "Indonesian"
    } else if (language.equals("ji")) {
        language = "yi"; // correct deprecated "Yiddish"
    }

    // ensure valid country code, if not well formed, it's omitted
    if (!region.matches("\\p{Alpha}{2}|\\p{Digit}{3}")) {
        region = "";
    }

     // variant subtags that begin with a letter must be at least 5 characters long
    if (!variant.matches("\\p{Alnum}{5,8}|\\p{Digit}\\p{Alnum}{3}")) {
        variant = "";
    }

    StringBuilder bcp47Tag = new StringBuilder(language);
    if (!region.isEmpty()) {
        bcp47Tag.append(separator).append(region);
    }

    if (!variant.isEmpty()) {
        bcp47Tag.append(separator).append(variant);
    }

    return bcp47Tag.toString();
@}

[Foreign(Language.ObjC)]
private static extern(iOS) string GetCurrentLocale()
@{
	NSString* language = NSLocale.preferredLanguages[0];

    if (language.length <= 2) {
        NSLocale* locale = NSLocale.currentLocale;
        NSString* localeId = locale.localeIdentifier;
        NSRange underscoreIndex = [localeId rangeOfString: @"_" options: NSBackwardsSearch];
        NSRange atSignIndex = [localeId rangeOfString: @"@"];

        if (underscoreIndex.location != NSNotFound) {
            if (atSignIndex.length == 0)
                language = [NSString stringWithFormat: @"%@%@", language, [localeId substringFromIndex: underscoreIndex.location]];
            else {
                NSRange localeRange = NSMakeRange(underscoreIndex.location, atSignIndex.location - underscoreIndex.location);
                language = [NSString stringWithFormat: @"%@%@", language, [localeId substringWithRange: localeRange]];
            }
        }
    }

    return [language stringByReplacingOccurrencesOfString: @"_" withString: @"-"];
@}

// Preview's implementations
public static extern(!Mobile) string GetCurrentLocale() {
	return "en-EN";
}

```

}

Is it problem with the packages?Should I use something like  
using Language; ???

---

<div class="post-metadata">

**Author:** ![Predrag\_Dislenkovic](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@Predrag\_Dislenkovic](https://forums.fusetools.com/u/Predrag_Dislenkovic)\
**Post date:** [March 13, 2018, 10:57am UTC](https://forums.fusetools.com/t/package-problem/6089/2 "2018-03-13T10:57:18Z")

</div>

It’s okay , I solved it by myself. 🙂  
I just deleted this uno and all binding with it.(JS).  
You should check the DeviceLocale.uno that You have on your repo.It has bugs with the Language package.

---

<div class="post-metadata">

**Author:** ![Remi\_Pedersen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/remi_pedersen/32/432_2.png) [@Remi\_Pedersen](https://forums.fusetools.com/u/Remi_Pedersen)\
**Post date:** [March 13, 2018, 11:01am UTC](https://forums.fusetools.com/t/package-problem/6089/3 "2018-03-13T11:01:09Z")

</div>

Which version of Fuse did you test this with?

I assume the code comes from [this repo](https://github.com/drslem/fuse-localization)?

I just tested it with Fuse 1.7.0 and there it worked just as expected for both Android preview and Android export.

---

<div class="post-metadata">

**Author:** ![Predrag\_Dislenkovic](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@Predrag\_Dislenkovic](https://forums.fusetools.com/u/Predrag_Dislenkovic)\
**Post date:** [March 14, 2018, 8:10am UTC](https://forums.fusetools.com/t/package-problem/6089/4 "2018-03-14T08:10:21Z")

</div>

I am using 1.5.0v , and as I understood the code , correct me if I’m wrong but the device.uno file is not needed.I deleted it and in the localization.js i commented this line:

setLocale(DeviceLocale.locale);

The thing is every label that I need to translate I write it in the .json files (in this ex. en-US and the others, with the KEY and the VALUE that goes along with it) and I call the localization.js in every page’s JS.It works like a charm.

What do you think , is it correct to do that ( delete the device.uno)?

Cheers.

---

<div class="post-metadata">

**Author:** ![Remi\_Pedersen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/remi_pedersen/32/432_2.png) [@Remi\_Pedersen](https://forums.fusetools.com/u/Remi_Pedersen)\
**Post date:** [March 14, 2018, 8:20am UTC](https://forums.fusetools.com/t/package-problem/6089/5 "2018-03-14T08:20:49Z")

</div>

`device.uno` has never been part of the [https://github.com/drslem/fuse-localization](https://github.com/drslem/fuse-localization) repo, so it is definitely not required if you just want the localization stuff. 🙂

---

<div class="post-metadata">

**Author:** ![Predrag\_Dislenkovic](https://avatars.discourse-cdn.com/v4/letter/p/c5a1d2/32.png) [@Predrag\_Dislenkovic](https://forums.fusetools.com/u/Predrag_Dislenkovic)\
**Post date:** [March 14, 2018, 8:32am UTC](https://forums.fusetools.com/t/package-problem/6089/6 "2018-03-14T08:32:50Z")

</div>

than why is DeviceLocale.uno called in localization.js?

unoproj code:

“Includes”: [  
“_",  
“DeviceLocale.uno”, \<–  
“Localization.js:Bundle”,  
"text/_.json:Bundle”  
]

localization.js:

var Observable = require(“FuseJS/Observable”);  
var Bundle = require(“FuseJS/Bundle”);  
var DeviceLocale = require(“DeviceLocale”); \<-  
loc = Observable();

var Locales = { “default”: “en-US.json”,  
“en-US”: “en-US.json”,  
“en-GB”: “en-GB.json”,  
“nb-NO”: “nb-NO.json”  
};

function setLocale(locale){  
if(locale in Locales) f = Locales[locale];  
else f = Locales[“default”];  
loc.value = JSON.parse(Bundle.readSync(“text/”+f));  
}

setLocale(DeviceLocale.locale); \<-

module.exports = {loc, setLocale};

---

<div class="post-metadata">

**Author:** ![Remi\_Pedersen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/remi_pedersen/32/432_2.png) [@Remi\_Pedersen](https://forums.fusetools.com/u/Remi_Pedersen)\
**Post date:** [March 14, 2018, 8:43am UTC](https://forums.fusetools.com/t/package-problem/6089/7 "2018-03-14T08:43:45Z")

</div>

`DeviceLocale.uno` belongs in the project. `device.uno` does not.

It was `device.uno` that you mentioned in your previous post:

> What do you think , is it correct to do that ( delete the device.uno)?

But _if you do not need to check which language the device uses_ (e.g. you don’t want to automatically give the user the language they’ve set on their phone) then you don’t need `DeviceLocale.uno` either. 🙂
