-
Notifications
You must be signed in to change notification settings - Fork 6
Downloading the Source Code
gignu edited this page May 30, 2022
·
2 revisions
- Create a new folder called
lib
inside your root directory - Inside
lib
create a new file and call itlanguage-encoding.min.js
- Make sure the encoding of your newly created file is either
UTF-8
orUTF-8 with BOM
before proceeding! - Go to https://unpkg.com/detect-file-encoding-and-language/umd/language-encoding.min.js and copy the code
- Paste it into
language-encoding.min.js
and save it - Use the code below to load
language-encoding.min.js
via the<script>
tag.
// index.html
<body>
<input type="file" id="my-input-field" />
<script src="lib/language-encoding.min.js"></script>
<script src="app.js"></script>
</body>
// app.js
document.getElementById("my-input-field").addEventListener("change", (e) => {
const file = e.target.files[0];
languageEncoding(file).then((fileInfo) => console.log(fileInfo));
// Possible result: { language: english, encoding: UTF-8, confidence: { encoding: 1, language: 1 } }
});