Skip to content

Instantly share code, notes, and snippets.

@plateaukao
plateaukao / l10n.yml
Created August 16, 2020 03:14
sample of l10n yml
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
@plateaukao
plateaukao / app_en.arb
Last active August 16, 2020 03:25
arb file for en
{
"@@locale": "en",
"hello_world": "Hello World!",
"@hello_world": {
"description": "The conventional newborn programmer greeting"
}
}
{
"@@locale": "zh",
"hello_world": "你好,世界"
}
@plateaukao
plateaukao / main.dart
Created August 16, 2020 03:28
dart example with AppLocalizations
import 'package:flutter/material.dart';
import 'package:l10n_demo/l10n/app_localizations.dart'; // Add this line.
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@plateaukao
plateaukao / myhomepage.dart
Last active August 16, 2020 03:31
flutter with translation
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// Replace the title line with the following:
title: Text(AppLocalizations.of(context).hello_world),
),
// The rest of the widget tree.
);
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
if (intent?.action == Intent.ACTION_SEND) {
var url = intent.getStringExtra(Intent.EXTRA_TEXT) ?: ""
handleSendText(url) // Handle text being sent
}
}
@RequiresApi(Build.VERSION_CODES.N)
class LiffShareTileService : TileService() {
...
override fun onClick() {
super.onClick()
// 將 LINE Share App的主畫面叫起
val intent = Intent(this, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
// what the heck! 這件事做在 onResume() 中是沒有用的。害我試了好久
val clipBoardManager = getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
val copiedString = clipBoardManager.primaryClip?.getItemAt(0)?.text?.toString() ?: ""
if (copiedString.isNotEmpty()) {
handleSendText(copiedString)
}
}
window.onload = function() {
const useNodeJS = true; // if you are not using a node server, set this value to false
const defaultLiffId = ""; // change the default LIFF value if you are not using a node server
// DO NOT CHANGE THIS
let myLiffId = "";
// if node is used, fetch the environment variable and pass it to the LIFF method
// otherwise, pass defaultLiffId
if (useNodeJS) {
function previewUrlInfo(url, isAutoSend = false) {
// handle facebook no preview issue
var oldUrl = new URL(url);
if (oldUrl.hostname.includes('facebook')) {
oldUrl.hostname = 'mobile.facebook.com';
}
...
...
}